Q:

Get token from a url in python3

I have a python code where i'm using credentials to get the token from the url. It is working from postman. But not from python3.
headers = {'Content-type': 'Application/json', 'Accept': 'Application/json'}
data={ "username" : "someuser", "authSource" : "ADS", "password" : "somepasswd"}
req = requests.post(('https://example.com/suite-api/api/auth/token/acquire', data, headers=headers).json())
print(req)

The code above is not working. It should generate a token with some random characters.
I expect the output as
7aaf-321b-82ab-7f55-2233891adb::5sde-3wqa-8sab

A:

Seems your post request is wrong. It should be something like
headers = {'Content-type': 'Application/json', 'Accept': 'Application/json'}
data={ "username" : "someuser", "authSource" : "ADS", "password" : "somepasswd"}
req = requests.post('https://example.com/suite-api/api/auth/token/acquire', data, headers=headers).json() #notice the () here
print(req)

Your () at requests is placed wrong.

