I am trying to get the access token via python using the following code
def get_suitecrm_token1():
“”"
Authenticate with SuiteCRM and get an access token.
“”"
print(“Inside get token”)
url = f"{SUITECRM_URL}/Api/access_token"
headers = {
"Content-Type": "application/vnd.api+json",
"Accept": "application/vnd.api+json",
}
data = {
"grant_type": "client_credentials",
"client_id": "5",
"client_secret": "W",
}
try:
response = requests.post(url, json=data, headers=headers)
print(f"Response: {response}")
if response.status_code == 200:
token_data = response.json()
return token_data.get("access_token")
else:
print(f"Error fetching token: {response.status_code}, {response.text}")
return None
except requests.exceptions.RequestException as e:
print(f"Request failed: {e}")
return None
The code will be used in a Django project. Unfortunately I am getting 404 Page not found error instead of token. I am using SuiteCRM 8.8. It is installed using PHP 8.2.23.
Is getting access_token broken in latest SuiteCRM or does it not work in PHP 8, still?
Please help.