Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scopes attribut are NULL #419

Open
Tchiboun opened this issue May 23, 2024 · 1 comment
Open

scopes attribut are NULL #419

Tchiboun opened this issue May 23, 2024 · 1 comment

Comments

@Tchiboun
Copy link

Hello,

Could you please help me to use your librairie ?
After authentificate on the provider, all the scope are NULL like openid, profile and email. But I've got no message, no warning.
How can I trace the execution of the code ? I'm beginner in OIDC...

Thanks.

@dapoddubny
Copy link

dapoddubny commented Jun 25, 2024

use Jumbojett\OpenIDConnectClient;
$oidcBaseUrl = getenv('OIDC_BASE_URL') ?: "";
$oidcClientId = getenv('OIDC_CLIENT_ID') ?: "";
$oidcClientSecret = getenv('OIDC_CLIENT_SECRET') ?: "";
$oidc = new OpenIDConnectClient(
  $oidcBaseUrl,
  $oidcClientId,
  $oidcClientSecret
);
if (getenv('OIDC_INSECURE') == "true") {
  $oidc->setVerifyHost(false);
  $oidc->setVerifyPeer(false);
  $oidc->setHttpUpgradeInsecureRequests(false);
}
$protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' ? 'https' : 'http';
$host = $_SERVER['SERVER_NAME'];
$port = $_SERVER['SERVER_PORT'];
if (($protocol == 'http' && $port != 80) || ($protocol == 'https' && $port != 443)) {
  $host .= ':' . $port;
}
$uri = '/callback.php';
$url = $protocol . '://' . $host . $uri;
$oidc->setRedirectURL($url);
$oidc->addScope(array('openid', 'profile', 'email'));
$oidc->authenticate();

$oidc->addScope(array('openid', 'profile', 'email')); -< this line adds scopes
Don't forget you need to set access_token to $_SESSION and check is it expired and if it is expired user refreshToken method to get the new access token. If refresh_token is expired use authenticate method again for full re auth

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants