Below is my $provider
object:
Using this library
$provider = new LeagueOAuth2ClientProviderGenericProvider([
'clientId' => $client_id,
'clientSecret' => $secret_value,
'redirectUri' => $callback_url,
'urlAuthorize' => "https://login.microsoftonline.com/" . $tenant_id . "/oauth2/authorize",
'urlAccessToken' => "https://login.microsoftonline.com/" . $tenant_id . "/oauth2/token",
'urlResourceOwnerDetails' => '',
]);
In my company account when I am logging in it is redirecting to below callback function and I am getting the access token under $_SESSION['access_token'] = $accessToken;
perfectly, and able to get email id and other details from this token, However when I am deploying the same code with same app configuration for my clients azure ad tenant, I am getting interaction_required
error.
$e->getMessage()
is printing interaction_required
only, is there way we can get some more info about this error what configuration is exactly missing in my clients azure ad account? At below line I am getting error, shall I print_r($e)
to get the whole message?
echo 'Authentication error: ' . $e->getMessage();
public function callback() {
$secret_value="XXX";
$client_id="XXX";
$tenant_id="XXX";
$provider = new LeagueOAuth2ClientProviderGenericProvider([
'clientId' => $client_id,
'clientSecret' => $secret_value,
'redirectUri' => $callback_url,
'urlAuthorize' => "https://login.microsoftonline.com/" . $tenant_id . "/oauth2/authorize",
'urlAccessToken' => "https://login.microsoftonline.com/" . $tenant_id . "/oauth2/token",
'urlResourceOwnerDetails' => '',
]);
if(isset($_GET['code'])) {
if (!isset($_GET['state']) || $_GET['state'] !== $_SESSION['oauth2state']) {
$this->logging($_GET['code'],"Invalid state parameter");
die('Invalid state parameter');
}
try {
// Exchange authorization code for access token
$accessToken = $provider->getAccessToken('authorization_code', [
'code' => $_GET['code'],
]);
$_SESSION['access_token'] = $accessToken;
header('Location: https://example.com/');
exit;
} catch (LeagueOAuth2ClientProviderExceptionIdentityProviderException $e) {
echo 'Authentication error: ' . $e->getMessage();
exit;
}
} elseif (isset($_GET['error'])) {
die('Error: ' . $_GET['error']);
}
}
Tried with My company account, working perfectly.
But for my client it is not working.
user25944704 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.