How do I complete my OAuth Google Login?
<p>My application has React and Redux running on the client side and Flask running on the server side.</p>

<p>I received a OAUTH token from Google on my client in the form of:</p>

<pre><code> Object { El: "109087143026456349612", Zi: Object, w3: Object, googleId:   
 "109087143026456349612", tokenObj: Object, tokenId:
 "eyJhbGciOiJSUzI1NiIsImtpZCI6IjUxNjEâ¦", accessToken: "ya29.Ci-
 AAyPxYI7qVyKp2QTwadhiVtc9Qgâ¦", profileObj: Object }
</code></pre>

<p>I sent this entire token object to my server via</p>

<pre><code> axios.post(`${local_env_url}/gconnect`, {returnData})
</code></pre>

<p>My Flask server has recognized with:</p>

<pre><code>@app.route('/gconnect', methods=['POST'])
def gconnect():
token = request.data
</code></pre>

<p>Where do i go from here?
On the docs it says that I can verify the token by sending it to this link:
'<a href="https://www.googleapis.com/oauth2/v3/tokeninfo?id_token=%s" rel="nofollow">https://www.googleapis.com/oauth2/v3/tokeninfo?id_token=%s</a>' %(tokenid)</p>

<p>but it's not clear if I'm sending the entire token object or just the access token value.</p>

<p>Steps are like this </p>

<ol>
<li>Get google auth data after user successfully connects to your app.</li>
<li>After a user successfully signs in, send the user's ID token to your server using HTTPS.</li>
<li>Then, on the server, verify the integrity of the ID token and retrieve the user's ID from the sub claim of the ID token. </li>
</ol>

<p>On server side you just need to send <code>id_token</code> and nothing else.</p>

<p>Now comes the verification of the integrity of the ID token passed to your blackened server which in your case is flask.</p>

<p>From server side you need to make a http request to validate the ID token to this end point - </p>

<pre><code>https://www.googleapis.com/oauth2/v3/tokeninfo?id_token=XYZ123
</code></pre>

<p>If the token is properly signed and valid, you will get a HTTP 200 response, where the body contains the JSON-formatted ID token claims.</p>

<p>You can get all the user info from the response received on server side.</p>

<p>To send the request to validate id_token you can use any python library to make http request or you can use google client library for python -</p>

<pre><code>from oauth2client import client, crypt

# (Receive token by HTTPS POST)

try:
    idinfo = client.verify_id_token(token, CLIENT_ID)
    # If multiple clients access the backend server:
    if idinfo['aud'] not in [ANDROID_CLIENT_ID, IOS_CLIENT_ID, WEB_CLIENT_ID]:
        raise crypt.AppIdentityError("Unrecognized client.")
    if idinfo['iss'] not in ['accounts.google.com', 'https://accounts.google.com']:
        raise crypt.AppIdentityError("Wrong issuer.")
    if idinfo['hd'] != APPS_DOMAIN_NAME:
        raise crypt.AppIdentityError("Wrong hosted domain.")
except crypt.AppIdentityError:
    # Invalid token
userid = idinfo['sub']
</code></pre>

<p>More info <a href="https://developers.google.com/identity/sign-in/web/backend-auth#using-a-google-api-client-library" rel="nofollow">here</a> - regarding how to use google client library.</p>

python reactjs flask oauth