def authorized(): resp = get_google().authorized_response() if resp is None: abort(401) google_token = resp['access_token'] session['google_token'] = (google_token, '') user_info = get_google().get('userinfo').data domain = user_info.get('hd', None) if domain != current_app.config['GOOGLE_APP_DOMAIN']: flash('Domain is not allowed') return redirect(url_for('pages.index')) user_info.update({'google_token': google_token}) AuthUser.objects(email=user_info["email"]).update_one(upsert=True, **user_info) return redirect(url_for('pages.index'))
def login(): callback = url_for('auth.authorized', _external=True) return get_google().authorize(callback=callback)