Open DavidWiesner opened 9 years ago
David,
Have you been able to run this code successfully?
Is this still an issue or can I close this?
@MendeleyStack: Rather than "closing" this, I suggest you make his edits to the source so we can all benefit downstream. The problem is easily replicable and easily solved, thanks to his well-written explanation, but only if you have credentials to fix the codebase.
Alternatively, please provide an alternative method for auto-refreshing expired tokens.
Thanks!
I dont know if it is related, but very regularly I get the following error:
ile \"/var/task/mendeley/auth.py\", line 31, in authenticate
token = oauth.fetch_token(self.token_url, auth=self.auth, scope=['all'])
File \"/var/task/requests_oauthlib/oauth2_session.py\", line 364, in fetch_token
r = hook(r)
File \"/var/task/mendeley/auth.py\", line 12, in handle_text_response
if rsp.headers['content-type'] == 'text/plain':
File \"/var/task/requests/structures.py\", line 52, in __getitem__
return self._store[key.lower()][1]
KeyError: 'content-type'
I authenticate using:
mendel = Mendeley(CLIENT_ID, CLIENT_SECRET)
session = mendel.start_client_credentials_flow().authenticate()
But I imagine the error happens whenever the token expires. How to fix it?
When I use your mendeley-api-python-example and the access token gets expired I expected the access token gets refreshed automatically, but it won´t.
So here in are the steps to reproduce:
expected result
the
access_token
will be refreshed with therefresh_token
actual result
TokenExpiredError
expected fix: using
MendeleyAuthorizationCodeTokenRefresher
I expected to fix this bug by using
MendeleyAuthorizationCodeTokenRefresher
in mendeley-example.py#L101 So I change the method to:actual result
TokenExpiredError
and log:No new refresh token given. Re-using old.
possible fix in
MendeleyAuthorizationCodeAuthenticator
the problem is
oauth.refresh_token
try to find a refresh token his object, but because theOAuth2Session
object is recreated this token must be passed explicit:This should be fixed the bug regards, david