I am trying to generate a oauth access token for experian's sandbox API (they give information on credit information). Their tutorial Says to run this (fake data) to get an access token:
curl -X POST
-d '{ "username":"[email protected]", "password":"YOURPASSWORD"}'
-H "Client_id: 3QC11Sm45ti8wEG0d9A5hma5XIlGG7U9"
-H "Client_secret: ipu3WQDqTEjqZDXW"
-H "Content-Type: application/json"
"https://sandbox-us-api.experian.com/oauth2/v1/token"
How would I run this in python? I tried this among a lot of other things:
data = { "username" : "[email protected]", "password":"YOURPASSWORD"}
headers = {"Client_id": "3QC11Sm45ti8wEG0d9A5hma5XIlGG7U9", "Client_secret": "ipu3WQDqTEjqZDXW", "Content-Type": "application/json"}
response = requests.post("https://sandbox-us-
api.experian.com/oauth2/v1/token", data=data, headers=headers)
Any help would be greatly appreciated
Almost there, just need to parse the response:
import json
data = { "username" : "[email protected]", "password":"YOURPASSWORD"}
headers = {"Client_id": "3QC11Sm45ti8wEG0d9A5hma5XIlGG7U9", "Client_secret": "ipu3WQDqTEjqZDXW", "Content-Type": "application/json"}
response = requests.post("https://sandbox-us-api.experian.com/oauth2/v1/token", data=data, headers=headers)
if response.status_code in [200]:
tok_dict = json.loads(response.text)
print(tok_dict)
issued_at = tok_dict["issued_at"]
expires_in = tok_dict["expires_in"]
token_type = tok_dict["token_type"]
access_token = tok_dict["access_token"]
else:
print(response.text)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With