Thank you for your response @SitaRam
I guess the Identity engine is revoked the “Resource owner grant type” flow. anyway I have followed the method you approached, below the response showing client_credentials not allowed but i have configured client_credentials for my application.
$oktaDomain = ‘https://your-okta-domain.okta.com’;
$clientId = ‘your-client-id’;
$clientSecret = ‘your-client-secret’;
$tokenUrl = $oktaDomain . ‘/oauth2/default/v1/token’;
// User credentials
$data = [
‘grant_type’ => ‘password’,
‘username’ => ‘admin@dnz.com’,
‘password’ => ‘Vision@2020’,
‘scope’ => ‘openid profile’ // Adjust scopes as needed
];
// Initialize cURL
$ch = curl_init();
// Set cURL options
curl_setopt($ch, CURLOPT_URL, $tokenUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_USERPWD, $clientId . ‘:’ . $clientSecret);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
// Execute the request
$response = curl_exec($ch);
// Check for errors
if (curl_errno($ch)) {
echo ‘Error:’ . curl_error($ch);
} else {
// Decode the response
$responseData = json_decode($response, true);
if (isset($responseData[‘access_token’])) {
echo 'Access Token: ’ . $responseData[‘access_token’];
} else {
echo 'Error: ’ . print_r($responseData, true);
}
}
// Close cURL session
curl_close($ch);
API Response:
Error: Array ( [error] => unauthorized_client [error_description] => The client is not authorized to use the provided grant type. Configured grant types: [authorization_code, client_credentials]. )