Open Tchiboun opened 1 month ago
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
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.