Skip to content
Advertisement

How can I get an oauth2 access_token using Python

For a project someone gave me this data that I have used in Postman for testing purposes:

In Postman this works perfectly.

Auth URL: https://api.example.com/oauth/access_token
Access Token URL: https://api.example.com/access_token
client ID: abcde
client secret: 12345
Token name: access_token
Grant type: Client Credentials

All I need is to get back the access token.

Once, I got the access token I can continue.

I have already tried several Python packages and some custom code, but somehow this seemingly simple task starts to create a real headache.

One exemple I tried:

JavaScript

Then I have got this one:

JavaScript

If this would work, what should I put into the code parameter

I really hope someone can help me out here.

Thanks in advance.

Advertisement

Answer

I was finally able to get it done by using the rauth library (pip install rauth).

This is the code I used:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement