See3D/views.py
def oauth2callback():
    """Receive and validate Google's id token, then use the 'sub' field to store and log the user in to a session."""
    if request.method == 'POST':
        token = request.form.get('idtoken')

        # Use Google's process to verify the received id token.
        try:
            idinfo = client.verify_id_token(token, '151432626794-3svgnd49h2fjmngk1cuatmrmna5n05jl.apps.googleusercontent.com')

            if idinfo['iss'] not in ['accounts.google.com', 'https://accounts.google.com']:
                raise crypt.AppIdentityError("Wrong issuer.")

        except crypt.AppIdentityError:
            flash('The submitted login token is invalid.')
            return "login failed"

        user = User.query.filter_by(sub=idinfo['sub']).first()

        # Add user to database if not already there.
        if not user:
            user = User(sub=idinfo['sub'], is_creator=False, email=idinfo['email'], name=idinfo['name'])

            db.session.add(user)
            db.session.commit()

        login_user(user, remember=False)
        return user.email

    elif request.method == 'GET':
        return redirect(url_for('index'))
Receive and validate Google's id token, then use the 'sub' field to store and log the user in to a session.
Receive and validate Google's id token, then use the 'sub' field to store and log the user in to a session.
Receive and validate Google ' s id token then use the ' sub ' field to store and log the user in to a session .
def oauth2callback():
    if request.method == 'POST':
        token = request.form.get('idtoken')
        try:
            idinfo = client.verify_id_token(token, '151432626794-3svgnd49h2fjmngk1cuatmrmna5n05jl.apps.googleusercontent.com')
            if idinfo['iss'] not in ['accounts.google.com', 'https://accounts.google.com']:
                raise crypt.AppIdentityError("Wrong issuer.")
        except crypt.AppIdentityError:
            flash('The submitted login token is invalid.')
            return "login failed"
        user = User.query.filter_by(sub=idinfo['sub']).first()
        if not user:
            user = User(sub=idinfo['sub'], is_creator=False, email=idinfo['email'], name=idinfo['name'])
            db.session.add(user)
            db.session.commit()
        login_user(user, remember=False)
        return user.email
    elif request.method == 'GET':
        return redirect(url_for('index'))
def oauth2callback ( ) : if request . method == 'POST' : token = request . form . get ( 'idtoken' ) try : idinfo = client . verify_id_token ( token , '151432626794-3svgnd49h2fjmngk1cuatmrmna5n05jl.apps.googleusercontent.com' ) if idinfo [ 'iss' ] not in [ 'accounts.google.com' , 'https://accounts.google.com' ] : raise crypt . AppIdentityError ( "Wrong issuer." ) except crypt . AppIdentityError : flash ( 'The submitted login token is invalid.' ) return "login failed" user = User . query . filter_by ( sub = idinfo [ 'sub' ] ) . first ( ) if not user : user = User ( sub = idinfo [ 'sub' ] , is_creator = False , email = idinfo [ 'email' ] , name = idinfo [ 'name' ] ) db . session . add ( user ) db . session . commit ( ) login_user ( user , remember = False ) return user . email elif request . method == 'GET' : return redirect ( url_for ( 'index' ) )
Receive and validate Google's id token, then use the 'sub' field to store and log the user in to a session.
Receive and validate Google ' s id token then use the ' sub ' field to store and log the user in to a session .
"""Receive and validate Google's id token, then use the 'sub' field to store and log the user in to a session.""" # Use Google's process to verify the received id token. # Add user to database if not already there.