python-unsplash
python-unsplash copied to clipboard
Authentication issues
I've been using the API for two months without any issues, up until a few days ago. There seems to be an issue with the Oauth token fetch.
To make sure the issue isn't on my side I created a new dummy application as follows:
from unsplash.api import Api
from unsplash.auth import Auth
client_id = "x"
client_secret = "x"
redirect_uri = "urn:ietf:wg:oauth:2.0:oob"
code = "x"
auth = Auth(client_id, client_secret, redirect_uri, code=code)
api = Api(auth)
api.user.me()
Running this code with a fresh authorization code gives the following error:
Traceback (most recent call last):
File "C:\...\Python\Python36-32\lib\site-packages\unsplash\auth.py", line 56, in __init__
self.access_token = self.get_access_token(code)
File "C:\...\Python\Python36-32\lib\site-packages\unsplash\auth.py", line 72, in get_access_token
code=code
File "C:\...\Python\Python36-32\lib\site-packages\requests_oauthlib\oauth2_session.py", line 244, in fetch_token
self._client.parse_request_body_response(r.text, scope=self.scope)
File "C:\...\Python\Python36-32\lib\site-packages\oauthlib\oauth2\rfc6749\clients\base.py", line 411, in parse_request_body_response
self.token = parse_token_response(body, scope=scope)
File "C:\...\Python\Python36-32\lib\site-packages\oauthlib\oauth2\rfc6749\parameters.py", line 379, in parse_token_response
validate_token_parameters(params)
File "C:\...\Python\Python36-32\lib\site-packages\oauthlib\oauth2\rfc6749\parameters.py", line 386, in validate_token_parameters
raise_from_error(params.get('error'), params)
File "C:\...\Python\Python36-32\lib\site-packages\oauthlib\oauth2\rfc6749\errors.py", line 415, in raise_from_error
raise cls(**kwargs)
oauthlib.oauth2.rfc6749.errors.InvalidGrantError: (invalid_grant) The provided authorization grant is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File ".\testauth.py", line 9, in <module>
auth = Auth(client_id, client_secret, redirect_uri, code=code)
File "C:\...\Python\Python36-32\lib\site-packages\unsplash\auth.py", line 59, in __init__
raise UnsplashAuthError(e)
unsplash.errors.UnsplashAuthError: Unsplash Authentication Error: (invalid_grant) The provided authorization grant is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client.
I'm using Python 3.6 and the version of the dependencies specified in the requirements.txt.
Thanks for any help.
I'm having the same issue.
Same issue, any news?
+1
+1 Any updates @yakupadakli ??
+1 Any updates @yakupadakli ??
For anybody still wondering, I wasn't able to find a solution but ended up using another wrapper that works seamlessly https://github.com/salvoventura/pyunsplash
Hello, you need to provide correct client_id, client_secret, redirect_uri and code that returns from redirect uri. You can get token in unsplash developer panel.
@yakupadakli How do I used already saved access token so that I don’t have to authorise again again ?
Can you give example ?