Skip to content

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

@emilcarr

Description

@emilcarr

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions