Hi fcaelen ,
First of all the token URL isn't correct and incomplete as well.
For OAuth 2.0, You need to follow the steps mentioned
1. hit the following URL manually or can make a GET request script :-
https://myCommunity/auth/oauth2/authorize?client_id=[CLIENT_ID]&response_type=code&redirect_uri=[REDIRECT_URI]
[REDIRECT_URI] is the URL you provide while registering your App under ADMIN>SYSTEM>API Apps .
It will redirect to the the provided [REDIRECT_URI] with code and tenant ID.
For Example -
https://[REDIRECT_URI]?code=[authorization_code]&tenant=[tenant_Id]
Fetch the "authorization code" which is URL Encoded (decode it into string) and pass it as described below in Step 2.
2. Make a POST Request to the given URL. Find the sample code below.
import requests
ACCESS_TOKEN_URL = "https://api.lithium.com/auth/v1/accessToken"
requests.post(
ACCESS_TOKEN_URL,
headers = {"Content-type" : "application/json", "client_id" : "[CLIENT_ID]"},
data = {
"code" : "[authorization_code]",
"client_id" : "[CLIENT_ID]",
"client_secret" : "[CLIENT_SECRET]",
"redirect_uri" : "[REDIRECT_URI]",
"grant_type" : "authorization_code"
}
)
ACCESS_TOKEN_URL for stage will be "https://api.stage.lithium.com/....."
Sample Response Body on success
{
"response": {
"status": "success",
"message": "OK",
"http_code": 200,
"data": {
"access_token": "o5IV0yIiNDj/5lNJ6doJh08LX6SsDwtkDXDVmhGvRtI=",
"expires_in": 86400,
"lithium_user_id": "2d8c95ed-21dc-4ba6-ab9f-d3eff9c928ce",
"refresh_token": "XAAWIWKr38W33SlqYooR9OEJW0um9DoyB/o843rdIxk=",
"token_type": "bearer"
}
}
}
"access_token" will be used to make the calls.
Accept it as solution if it solves your query.
Thanks