Authentication Error - The endpoint does not support the provided HTTP method

Hello everybody,

I’m implementing authentication in Okta and the login page loads normally. But I have some errors.

This is the URL for the login page:

https://dev-13205505.okta.com/oauth2/default/v1/authorize?redirect_uri=https://cmsdev.br.ibm.com/public/index.php/authorization-code/callback&response_type=code&client_id=0oa67z8u1oMlVbPxV5d7&state=738a8d7502844478a12e&code_challenge=iMCW7OGCd6CmBe3xDLJTUrhYWq5E8J45hi-uz1JWwVc&code_challenge_method=S256&nonce=nonce&scope=openid+profile+email

When I enter username and password, the error message returns:

This is the authenticated URL in Okta:

https://cmsdev.br.ibm.com/public/index.php/authorization-code/callback?code=4_kiSXI5lqyTgK-sslCo8Q137Q7zutj9z0JPvG8eXHM&state=738a8d7502844478a12e

When accessing the URL the error message appears

// https://dev-13205505.okta.com/oauth2/default/v1/token
{
“errorCode”: “E0000022”,
“errorSummary”: “The endpoint does not support the provided HTTP method”,
“errorLink”: “E0000022”,
“errorId”: “oaebDnffe31Qny6hmRCJKUnNQ”,
“errorCauses”: [
]
}

Can anyone help?

Are you trying to make a POST to the /token endpoint to exchange the authorization code (code URL param) sent back from Okta to the redirect_uri?

Hello @andrea ,

I’m trying to set the CURL return session, but I found that you don’t have CURL installed on the server, maybe that’s why the code is giving error.

$token_endpoint = $_ENV[‘OKTA_OAUTH2_ISSUER’].‘/v1/token’;

$ch = curl_init($token_endpoint);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([
‘grant_type’ => ‘authorization_code’,
‘code’ => $_GET[‘code’],
‘code_verifier’ => $_SESSION[‘oauth_code_verifier’],
‘redirect_uri’ => $_ENV[‘OKTA_OAUTH2_REDIRECT_URI’],
‘client_id’ => $_ENV[‘OKTA_OAUTH2_CLIENT_ID’],
‘client_secret’ => $_ENV[‘OKTA_OAUTH2_CLIENT_SECRET’],
]));

$response = json_decode(curl_exec($ch), true);

$_SESSION[‘okta_id_token’] = $response[‘id_token’];

Does not run CURL.