标签: social-auth-app-django

social-auth-app-django:刷新 access_token

我将 social-auth-app-django 用于我的 django 网站。登录一切正常,但在令牌过期后。我不能再访问谷歌的用户数据了。我找到了如何刷新令牌,但它给出了

 File "/mnt/s/github/nascentapp/app/booking/management/commands/sendmail.py", line 17, in handle
    new_token = self.get_token(user=booking_user, provider='google-oauth2')
  File "/mnt/s/github/nascentapp/app/booking/management/commands/sendmail.py", line 28, in get_token
    social.refresh_token(strategy)
  File "/home/sander/.local/share/virtualenvs/app-YMrBBUv3/lib/python3.6/site-packages/social_core/storage.py", line 58, in refresh_token
    response = backend.refresh_token(token, *args, **kwargs)
  File "/home/sander/.local/share/virtualenvs/app-YMrBBUv3/lib/python3.6/site-packages/social_core/backends/oauth.py", line 438, in refresh_token
    request = self.request(url, **request_args)
  File "/home/sander/.local/share/virtualenvs/app-YMrBBUv3/lib/python3.6/site-packages/social_core/backends/base.py", line 234, in request
    response.raise_for_status()
  File "/home/sander/.local/share/virtualenvs/app-YMrBBUv3/lib/python3.6/site-packages/requests/models.py", line 941, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://accounts.google.com/o/oauth2/token
Run Code Online (Sandbox Code Playgroud)

这是我的一些代码

def get_token(self, user, provider):
        social = user.social_auth.get(provider=provider)
        print('This is social of …
Run Code Online (Sandbox Code Playgroud)

python django python-3.x social-auth-app-django

8
推荐指数
1
解决办法
402
查看次数