def authorized(): try: resp = google.authorized_response() except: current_app.logger.exception( 'Error during handling the oauth response') abort(400) if resp is None: error_message = 'Access denied' if 'error_reason' in request.args: error_message += ': reason=%s error=%s' % ( request.args['error_reason'], request.args['error_description']) return error_message # don't leak access_token into the session cookie # session['google_token'] = (resp['access_token'], '') do_redirect = session.pop('redirect_path', None) me = google.get('userinfo', token=resp['access_token']).data session['user_info'] = me if do_redirect: return redirect(do_redirect) return redirect('/')
def authorized(): try: resp = google.authorized_response() except Exception: current_app.logger.exception( "Error during handling the oauth response") abort(400) if resp is None: error_message = "Access denied" if "error_reason" in request.args: error_message += ": reason=%s error=%s" % ( request.args["error_reason"], request.args["error_description"], ) return error_message # don't leak access_token into the session cookie # session['google_token'] = (resp['access_token'], '') do_redirect = session.pop("redirect_path", None) me = google.get("userinfo", token=resp["access_token"]).data session["user_info"] = me if do_redirect: return redirect(do_redirect) return redirect("/")
def is_authenticated(): if 'user_info' in session: return True if 'google_token' not in session: return False data = google.get('userinfo').data if data.get('error', False): del session['google_token'] return False session['user_info'] = data return True
def is_authenticated(): if "user_info" in session: return True if "google_token" not in session: return False data = google.get("userinfo").data if data.get("error", False): del session["google_token"] return False session["user_info"] = data return True