hello -
i have had much success following this example, but so far have been unsuccessful at getting the nickname, picture, etc, to show as specified in the scope:
use Auth0\SDK\Auth0;
use Auth0\SDK\Exception\CoreException;
use Auth0\SDK\Exception\ApiException;
// Handle errors sent back by Auth0.
if (! empty($_GET['error']) || ! empty($_GET['error_description'])) {
printf( '<h1>Error</h1><p>%s</p>', htmlspecialchars( $_GET['error_description'] ) );
die();
}
// Initialize the Auth0 class with required credentials.
$auth0 = new Auth0([
'domain' => 'dev-y-XXX.auth0.com',
'client_id' => 'XXXXXXX3',
'client_secret' => '2XXXXXXXXXXXXXm',
'redirect_uri' => 'https://DOMAIN.COM/login.php',
'scope' => 'openid email name nickname picture',
// The scope determines what data is provided by the /userinfo endpoint.
// There must be at least one valid scope included here.
]);
// If there is a user persisted (PHP session by default), return that.
// Otherwise, look for a "state" and "code" URL parameter to validate and exchange.
// If the state validation and code exchange are successful, return `userinfo`.
try {
$userinfo = $auth0->getUser();
} catch (CoreException $e) {
// Invalid state or session already exists.
die( $e->getMessage() );
} catch (ApiException $e) {
// Access token not present.
die( $e->getMessage() );
}
// No user information so redirect to the Universal Login Page.
if (empty($userinfo)) {
$auth0->login();
}
// We either have a persisted user or a successful code exchange.
var_dump($userinfo);
// This is where a user record in a local database could be retrieved or created.
// End with a redirect to a new page.
why am i not seeing the extra values i asked for? all i am seeing is this:
array(3) { [“sub”]=> string(35) “google-oauth2|114113878629589347134” [“email”]=> string(20) “mark@email.com” [“email_verified”]=> bool(true) }
thank you very much.