# Pass contacts.readonly scope to google IDP

**URL:** <https://community.auth0.com/t/pass-contacts-readonly-scope-to-google-idp/14570>\
**Category:** Get Help\
**Tags:** php\
**Created:** [August 22, 2018, 5:52pm UTC](https://community.auth0.com/t/pass-contacts-readonly-scope-to-google-idp/14570 "2018-08-22T17:52:09Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ben\_Smith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ben_smith/32/6235_2.png) [@Ben\_Smith](https://community.auth0.com/u/Ben_Smith)\
**Post date:** [August 22, 2018, 5:52pm UTC](https://community.auth0.com/t/pass-contacts-readonly-scope-to-google-idp/14570/1 "2018-08-22T17:52:10Z")

</div>

Hello, trying to pass the [https://www.googleapis.com/auth/contacts.readonly](https://www.googleapis.com/auth/contacts.readonly) scope to google when a user logs in using their gmail account. This scope isn’t listed on the google social connection auth0 page. I’m trying to follow the recommendation [here](https://auth0.com/docs/connections/adding-scopes-for-an-external-idp#2-pass-scopes-to-authorize-endpoint) to authorize this endpoint upon login using [auth0-PHP](https://github.com/auth0/auth0-PHP).

```
 use Auth0\SDK\Auth0;
$auth0 = new Auth0([
  'domain' => getenv('AUTH0_DOMAIN'),
  'client_id' => getenv('AUTH0_CLIENT_ID'),
  'client_secret' => getenv('AUTH0_CLIENT_SECRET'),
  'redirect_uri' => getenv('AUTH0_CALLBACK_URL'),
  'audience' => 'https://ultrasoundjelly.auth0.com/userinfo',
  'scope' => 'offline_access profile openid email',
  'persist_id_token' => true,
  'persist_access_token' => true,
  'persist_refresh_token' => true,
  'connection_scope' => 'https://www.googleapis.com/auth/contacts.readonly',
  'connection' => 'google-oauth2'
]);

```

But when a user clicks the login button, the http query string that is built and passed onto auth0 doesn’t include these connection options.

---

<div class="post-metadata">

**Author:** ![josh.cunningham](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/josh.cunningham/32/16289_2.png) [@josh.cunningham](https://community.auth0.com/u/josh.cunningham)\
**Post date:** [August 22, 2018, 8:22pm UTC](https://community.auth0.com/t/pass-contacts-readonly-scope-to-google-idp/14570/2 "2018-08-22T20:22:38Z")

</div>

Hi @Ben_Smith … You’ll need to pass those to the `login` method for that to work. See here:

> <https://github.com/auth0/auth0-PHP/blob/main/src/Auth0.php#L328>

You instantiate without those config params, then pass that connection as the second parameter in the login method. General example here:

> **[GitHub - auth0/auth0-PHP: PHP SDK for Auth0 Authentication and Management APIs.](https://github.com/auth0/auth0-PHP#login)**
>
> PHP SDK for Auth0 Authentication and Management APIs. - GitHub - auth0/auth0-PHP: PHP SDK for Auth0 Authentication and Management APIs.

Like:

```php
$auth0->login(
    null, 
    'google-oauth2', 
    [ 
        'connection_scope' => 'https://www.googleapis.com/auth/contacts.readonly' 
    ]
)

```

---

<div class="post-metadata">

**Author:** ![Ben\_Smith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ben_smith/32/6235_2.png) [@Ben\_Smith](https://community.auth0.com/u/Ben_Smith)\
**Post date:** [August 22, 2018, 8:34pm UTC](https://community.auth0.com/t/pass-contacts-readonly-scope-to-google-idp/14570/3 "2018-08-22T20:34:45Z")

</div>

ah, I see. However, when I instantiate the login this way I’m taken straight to google to login, rather than the Universal Login page where I offer google-oauth2 as well as Username-Password-Authentication.

---

<div class="post-metadata">

**Author:** ![josh.cunningham](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/josh.cunningham/32/16289_2.png) [@josh.cunningham](https://community.auth0.com/u/josh.cunningham)\
**Post date:** [August 22, 2018, 10:14pm UTC](https://community.auth0.com/t/pass-contacts-readonly-scope-to-google-idp/14570/4 "2018-08-22T22:14:53Z")

</div>

Yes, that’s what the `connection` parameter does, it specifies the connection to use instead of using all available. You can try without that but I’m not totally sure if it would work. I just tried it with logging in using a DB connection and it authenticated fine, even with those scopes there.

---

<div class="post-metadata">

**Author:** ![Ben\_Smith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ben_smith/32/6235_2.png) [@Ben\_Smith](https://community.auth0.com/u/Ben_Smith)\
**Post date:** [August 22, 2018, 11:10pm UTC](https://community.auth0.com/t/pass-contacts-readonly-scope-to-google-idp/14570/5 "2018-08-22T23:10:34Z")

</div>

I’d still like the user to go through the universal login page and select their connection type. On a hunch I added my connections as an array:  
$auth0-\>login(  
null,  
[‘google-oauth2’,‘Username-Password-Authentication’],  
[  
‘connection\_scope’ =\> ‘[https://www.googleapis.com/auth/contacts.readonly](https://www.googleapis.com/auth/contacts.readonly)’  
]  
);  
But this just returned an invalid request on immediate redirect to my callback URL. “the%20connection%20was%20not%20found”

---

<div class="post-metadata">

**Author:** ![Ben\_Smith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ben_smith/32/6235_2.png) [@Ben\_Smith](https://community.auth0.com/u/Ben_Smith)\
**Post date:** [August 23, 2018, 12:25am UTC](https://community.auth0.com/t/pass-contacts-readonly-scope-to-google-idp/14570/6 "2018-08-23T00:25:43Z")

</div>

OK, removing the connections worked I _think_. I need to get google to re-enable my app to see. Thanks.

---

<div class="post-metadata">

**Author:** ![josh.cunningham](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/josh.cunningham/32/16289_2.png) [@josh.cunningham](https://community.auth0.com/u/josh.cunningham)\
**Post date:** [August 23, 2018, 9:39pm UTC](https://community.auth0.com/t/pass-contacts-readonly-scope-to-google-idp/14570/7 "2018-08-23T21:39:21Z")

</div>

As you say, that `connection` parameter is a single value. Leave that off to show all connections on the login page.

As for the scopes … even if that works, I’m not sure what would happen if those were sent to another connection. Best case they are ignored, worst case they are rejected with an error.

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [July 26, 2019, 9:32am UTC](https://community.auth0.com/t/pass-contacts-readonly-scope-to-google-idp/14570/8 "2019-07-26T09:32:44Z")

</div>


