Concur API Authorization using Python
In order to make calls to the the Concur API, you must first make a call to the Authorization API to receive a secure token that will be used each time you make a call to the Concur API. The token expires within 60 minutes, and there are ways to refresh it, but in this post we will merely show how to get a token issued in Python.
Note that this code requires credentials issued by Concur in order to access the API.
import requests
import json
# Base URL for Concur API Authorization
oauth2_base="https://us.api.concursolutions.com/oauth2/v0/token"
# Concur issued credentials - the next 5 lines - change to your credentia;s
username="MYID@example.com"
password="XXXXXXXX"
grant_type = "password" #Note this is for the type of grant
client_id="abcdefg123456789"
client_secret="9999999999-abcdef"
req_auth = requests.post(oauth2_base,data={'username':username,'password':password,'grant_type':grant_type,'client_secret':client_secret,'client_id':client_id})
# Minimum level of error checking for demonstrative purposes ! Do better in your application code
if req_auth.status_code == 200:
print (req_auth.text)