Error storing oauth credentials in session when authenticating with Google+ Error storing oauth credentials in session when authenticating with Google+ flask flask

Error storing oauth credentials in session when authenticating with Google+


You are trying to store the credentials object, rather than the actual credential data, in the session. The session data is serialized with JSON, so all data in it must be JSON serializable.

For a hint at what you actually need to store in the session to use the authentication you just performed, you can look at your request to /userinfo, where you send credentials.access_token.

The access token is typically what you need to remember after any oauth cycle. Don't store the credentials object, just store the access token.

# remove the session['credentials'] linelogin_session['access_token'] = credentials.access_token

Now you can use this token from the session in other routes to make other api calls.


I had a similar issue and was able to convert the credentials object to json via

login_session['credentials'] = credentials.to_json()