Getting 404 error while trying to get access_token

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.

Hello,

it’s working like a charm.
Probably the request URL is wrong?

I’m using:

http://suitecrm88.demo/legacy/Api/access_token

Maybe you need to add the legacy folder to your URL?

Bastian is correct!

Thanks Bastian for looking into this and giving solution. Unfortunately adding legacy to the URL is also giving me the same error :frowning:

Thanks RSP. Unfortunately it is not working for me :frowning:

Checkout the video: