Getting picture, nickname, etc in PHP

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'] ) );

// Initialize the Auth0 class with required credentials.
$auth0 = new Auth0([
  'domain' => '',
  '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)) {

// We either have a persisted user or a successful code exchange.

// 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) “” [“email_verified”]=> bool(true) }

thank you very much.

1 Like

Hello edwardsmarkf!

Have you tried using the “profile” scope instead of “name nickname picture”? According to these docs, the “profile” scope should return those three user attributes:


Please @edwardsmarkf let us know if that solved the issue!

hello Konrad -

yes indeed that solved the problem, which is very good news indeed!

however (BIG HOWEVER) this was far far more difficult than it needed to be. Auth0 could have saved me a month of work simply by including this in the original PHP example:

‘scope’ => ‘openid profile email name nickname picture’,

so when i look in my “Configure Auth0 PHP SDK” index.php example file, i only see the following:

$auth0 = new Auth0([
‘domain’ => ‘’,
‘client_id’ => ‘CLIENTS ID’,
‘client_secret’ => ‘YOUR_CLIENT_SECRET’,
‘redirect_uri’ => ‘’,
‘persist_id_token’ => true,
‘persist_access_token’ => true,
‘persist_refresh_token’ => true,

had the ‘scope’ been included, i would be much further along in my project now.

i would strongly encourage the Auth0.php team to fix this, since it might help some other newbie.

1 Like

Thanks a lot for providing us with that feedback! Really stoked that you were able to make progress with @thomas.osborn knowledge!

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.