Make google update token via python social auth

We are working on a project that depends on the PSA (0.2.1) for authentication with google oauth2 (offline). Somehow we lost some updated tokens of some users, we want to force these users to RE-AUTHENTICATE so that we can get a new update token from google

we tried both:

  • Diconnect for users using / diconnect / google -oauth2, we got a NotAllowedToDisconnect exception even after removing social.pipeline.disconnect.allowed_to_disconnectfrom SOCIAL_AUTH_DISCONNECT_PIPELINE, we did not get any exception, but when the user is re-authenticated, there is no refreh_token in google answer
  • add assert_prompt = force to 'account: social: begin' url but it does not return refresh_token

Any idea would be highly appreciated.

Update. We tried to use {% url 'account:social:begin' 'google-oauth2' %}?approval_prompt=force&next=/for forced approval for certain users (with missing tokens), but this does not seem to affect google oauth.

thank

+4
source share
1 answer

Using this setting does the trick:

SOCIAL_AUTH_GOOGLE_OAUTH2_AUTH_EXTRA_ARGUMENTS = {
    'access_type': 'offline',
    'approval_prompt': 'force'
}

Use the sample example at http://psa.matiasaguirre.net/docs/use_cases.html#re-prompt-google-oauth2-users-to-refresh-the-refresh-token

+4
source

All Articles