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

Request is unauthorised when using a (valid) creator access token. #29

Open
emilcarr opened this issue Feb 6, 2019 · 2 comments
Open

Comments

@emilcarr
Copy link

emilcarr commented Feb 6, 2019

I want to use the API to fetch data from creators I support on Patreon with my own account. I created a client and found my creator access token.

import patreon,json

client_id = "    " # My client ID
client_secret = "    " # My client secret
oauth_client = patreon.OAuth(client_id, client_secret)

tokens = {}
with open('patreontokens', 'r') as tfile: # Creator access and refresh tokens stored in a file
    tokens = json.loads(tfile.read())
    tokens = oauth_client.refresh_token(tokens["refresh_token"]) # Refresh the tokens
    
with open('patreontokens', 'w') as tfile:
    tfile.write(json.dumps(tokens))

creator_access_token=tokens["access_token"]
api_client = patreon.API(access_token)

ident = api_client.get_identity()
print(ident)

I read about a similar issue here which is why I am refreshing the token.

The output of the program is:

{'errors': [{'code': 1, 'code_name': 'Unauthorized', 'detail': "The server could not verify that you are authorized to access the URL requested.  You either supplied the wrong credentials (e.g. a bad password), or your browser doesn't understand how to supply the credentials required.", 'id': 'ca7835a3-90f2-4d1e-aa99-188a9efc5285', 'status': '401', 'title': 'Unauthorized'}]}

I have confirmed by doing print(token) that the refreshed token matches the one given to me at https://www.patreon.com/portal/registration/register-clients

@Midorina
Copy link

Midorina commented Jul 1, 2019

I am having the same issue but there's no response here even though this issue has been open for 5 months. Idk what to do.

@Midorina
Copy link

Midorina commented Jul 5, 2019

I just found out the issue - You have to choose the API version as v2 on your API client. It refuses v2 requests otherwise.

It doesn't let you edit it, so you just need to re-create your client with v2 API and you're good to go.

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

2 participants