Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Authentication issues #6

Open
IgnaceMaes opened this issue Jul 23, 2018 · 7 comments
Open

Authentication issues #6

IgnaceMaes opened this issue Jul 23, 2018 · 7 comments

Comments

@IgnaceMaes
Copy link

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.

@thejoltjoker
Copy link

I'm having the same issue.

@lednhatkhanh
Copy link

Same issue, any news?

@ming4J
Copy link

ming4J commented Jul 13, 2019

+1

@adiathavas
Copy link

+1 Any updates @yakupadakli ??

@adiathavas
Copy link

adiathavas commented Jul 19, 2019

+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

@yakupadakli
Copy link
Owner

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.

Screenshot 2023-11-02 at 16 13 52

@khurshid-alam
Copy link

@yakupadakli How do I used already saved access token so that I don’t have to authorise again again ?

Can you give example ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants