Github/facebook & php

Could I please see an example Auth0-facebook PHP login?

After carefully reviewing the facebook-php oauth2 code and thePhpLeague facebook interface, both of them are specifying the default_graph_version value, so i tried to include it like so:

$auth0 = new Auth0([
‘default_graph_version’ => ‘v3.2’,

But unfortunately this did not work.

Hey there!

As I’ve said in another post you started, the PHPLeague Facebook interface you reference is not developed by Auth0 thus we are not able to provide you with any help on that however we do have our own resources on PHP and connecting it with Facebook:

ok thank you - i got a LOT farther along that time! :smile:

what was particularly confusing is that in order to include FaceBook in an app that already successfully uses Google, i had to add one line to the simple code provided to me from the app “quick-start” PHP example:

‘scope’ => ‘openid email name nickname picture’, /* add this line* /

this was very confusing, since i just assumed the very simple PHP example provided to me would work with any social media, not just Google.

suggstion: include this line in the PHP example which is displayed when the app is created.

however, this did cause one more very minor issue which i am asking about here.

Thank you I will pass that feedback to our Docs team!

hi Konrad -

As a newbie, this really was very confusing and time-consuming. the example “quick-code” generated in “Configure Auth0 PHP SDK” does not include the scope.

here are the results i am seeing:

AUTH0: with scope:

Hello !array(3) { [“sub”]=> string(30) “auth0|5d9ca5804c5a1c0e1ea2b0fa” [“email”]=> string(20) “” [“email_verified”]=> bool(true) }

AUTH0: without scope:

Hello!array(7) { [“sub”]=> string(30) “auth0|5d9ca5804c5a1c0e1ea2b0fa” [“nickname”]=> string(4) “mark” [“name”]=> string(20) “” [“picture”]=> string(122) “” [“updated_at”]=> string(24) “2019-10-29T15:34:01.287Z” [“email”]=> string(20) “” [“email_verified”]=> bool(true) }

FACEBOOK: with scope:

Hello !array(3) { [“sub”]=> string(24) “facebook|568242963910810” [“email”]=> string(32) “” [“email_verified”]=> bool(true) }

FACEBOOK: without scope:

ERROR! This page isnt working redirected you too many times.

GOOGLE: with scope:

Hello !array(3) { [“sub”]=> string(35) “google-oauth2|114113878629589347134” [“email”]=> string(20) “” [“email_verified”]=> bool(true) }

GOOGLE: without scope:

Hello Mark Edwards!array(11) { [“sub”]=> string(35) “google-oauth2|114113878629589347134” [“given_name”]=> string(4) “Mark” [“family_name”]=> string(7) “Edwards” [“nickname”]=> string(4) “mark” [“name”]=> string(12) “Mark Edwards” [“picture”]=> string(83) “” [“gender”]=> string(5) “other” [“locale”]=> string(2) “en” [“updated_at”]=> string(24) “2019-10-29T15:28:01.605Z” [“email”]=> string(20) “” [“email_verified”]=> bool(true) }

GITHUB with scope:

Hello !array(2) { [“sub”]=> string(14) “github|2924002” [“email”]=> string(22) “” }

GITHUB without scope:

ERROR! This page isnt working redirected you too many times.

MSN with scope:

Hello !array(3) { [“sub”]=> string(28) “windowslive|a2cd40fdb7dbcb5b” [“email”]=> string(26) “” [“email_verified”]=> bool(true) }

MSN without scope:

This page isnt working redirected you too many times.

here is the code i am using (below). i am still wondering why including the scope fixes all the problems but i cannot extract name, picture, etc ??

$auth0 = new Auth0([
  'domain' => '',
  'client_id' => 'LXXXXXXXXXXXXX3',
  'client_secret' => '2XXXXXXXXXXXXXXXXXm',
  'redirect_uri' => '',
//'scope' => 'openid email name nickname picture',  //needs to be included for facebook, github, and msn
  'persist_id_token' => true,
  'persist_access_token' => true,
  'persist_refresh_token' => true,

error_log('index.php:  NOW trying to get userInfo.');

$userInfo = $auth0->getUser();

error_log('index.php:  $userInfo: ' . print_r($userInfo,1));

if (!$userInfo) {
error_log('logging in:');
                                                //echo '<a href="login.php">Log In</a>';
    // We have no user info
    // See below for how to add a login link
} else {
        error_log('We have userInfo ');
        printf( "Hello %s!", htmlspecialchars( $userInfo['name'] ) );
    // User is authenticated
    // See below for how to display user information

i know many people who would not have stuck with this and identified the issue! could you please find out for me why why the scope is not returning picture and name?? :slight_smile:

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