Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 刷新令牌会导致OAuthError_Python_Oauth 2.0_Github Api_Authlib - Fatal编程技术网

Python 刷新令牌会导致OAuthError

Python 刷新令牌会导致OAuthError,python,oauth-2.0,github-api,authlib,Python,Oauth 2.0,Github Api,Authlib,我正在使用Authlib库构建与Github的集成,需要刷新访问令牌。我在Authlib库中调用refresh_token(),如下所示: my_token = {'refresh_token':'a_long_refresh_token_string', 'access_token': "a_long_access_token", 'expires_at': 1596745728.0, 'expires

我正在使用Authlib库构建与Github的集成,需要刷新访问令牌。我在Authlib库中调用refresh_token(),如下所示:

my_token = {'refresh_token':'a_long_refresh_token_string',
            'access_token': "a_long_access_token",
            'expires_at': 1596745728.0,
            'expires_in': 28800.0}

oauth_session = OAuth2Session(client_id,client_secret, authorization_endpoint="https://github.com/login/oauth/authorize", token_endpoint="https://github.com/login/oauth/access_token", token=my_token, grant_type='refresh_token')

new_token = oauth_session.refresh_token(url="https://github.com/login/oauth/access_token")

# Tried this too, but generates the same error    
# new_token = oauth_session.refresh_token(url="https://github.com/login/oauth/access_token", client_id=client_id, client_secret=client_secret) 
但它始终会导致OAuthError。以下是完整的堆栈跟踪:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/root/user/dev/venvs/pyenv/lib64/python3.7/site-packages/authlib/oauth2/client.py", line 264, in refresh_token
    auth=auth, **session_kwargs)
  File "/root/user/dev/venvs/pyenv/lib64/python3.7/site-packages/authlib/oauth2/client.py", line 275, in _refresh_token
    token = self.parse_response_token(resp.json())
  File "/root/user/dev/venvs/pyenv/lib64/python3.7/site-packages/authlib/oauth2/client.py", line 380, in parse_response_token
    self.handle_error(error, description)
  File "/root/user/dev/venvs/pyenv/lib64/python3.7/site-packages/authlib/integrations/requests_client/oauth2_session.py", line 117, in handle_error
    raise OAuthError(error_type, error_description)
authlib.integrations.base_client.errors.OAuthError: bad_refresh_token: The refresh token passed is incorrect or expired.
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
文件“/root/user/dev/venvs/pyenv/lib64/python3.7/site packages/authlib/oauth2/client.py”,第264行,在刷新令牌中
auth=auth,**会话(kwargs)
文件“/root/user/dev/venvs/pyenv/lib64/python3.7/site packages/authlib/oauth2/client.py”,第275行,在刷新令牌中
token=self.parse\u response\u token(resp.json())
文件“/root/user/dev/venvs/pyenv/lib64/python3.7/site packages/authlib/oauth2/client.py”,第380行,在parse_response_令牌中
self.handle\u错误(错误,描述)
文件“/root/user/dev/venvs/pyenv/lib64/python3.7/site packages/authlib/integrations/requests\u client/oauth2\u session.py”,handle\u error中的第117行
引发OAuthError(错误类型、错误描述)

authlib.integrations.base\u client.errors.OAuthError:错误的\u刷新\u令牌:传递的刷新令牌不正确或已过期。

在获取访问令牌和尝试刷新它之间,我没有卸载Github应用程序。你知道我做错了什么吗?

我也有同样的问题。。。我似乎无法为我的GitHub应用刷新令牌。@SamStern我最终将GitHub应用切换为使用非过期令牌,这解决了问题。错误的\u刷新\u令牌:传递的刷新令牌不正确或已过期。此消息由GitHub返回。我稍后会核实。我也有同样的问题。。。我似乎无法为我的GitHub应用刷新令牌。@SamStern我最终将GitHub应用切换为使用非过期令牌,这解决了问题。错误的\u刷新\u令牌:传递的刷新令牌不正确或已过期。此消息由GitHub返回。我稍后再核实。