Skip to content

Authentication issues #6

Open
Open

Description

@IgnaceMaes

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.

Activity

  1. thejoltjoker commented on Oct 12, 2018

    @thejoltjoker

    I'm having the same issue.

  2. lednhatkhanh commented on Apr 17, 2019

    @lednhatkhanh

    Same issue, any news?

  3. ming4J commented on Jul 13, 2019

    @ming4J

    +1

  4. adiathavas commented on Jul 19, 2019

    @adiathavas

    +1 Any updates @yakupadakli ??

  5. adiathavas commented on Jul 19, 2019

    @adiathavas

    +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

  6. yakupadakli commented on Nov 2, 2023

    @yakupadakli
    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
  7. khurshid-alam commented on Nov 29, 2023

    @khurshid-alam

    @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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions