# Additional scopes in a custom login page

**URL:** <https://community.auth0.com/t/additional-scopes-in-a-custom-login-page/55889>\
**Category:** Get Help\
**Tags:** scopes, custom-login, login\
**Created:** [January 8, 2021, 12:43pm UTC](https://community.auth0.com/t/additional-scopes-in-a-custom-login-page/55889 "2021-01-08T12:43:14Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![mark.hall](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/mark.hall/32/12776_2.png) [@mark.hall](https://community.auth0.com/u/mark.hall)\
**Post date:** [January 8, 2021, 12:43pm UTC](https://community.auth0.com/t/additional-scopes-in-a-custom-login-page/55889/1 "2021-01-08T12:43:14Z")

</div>

How do I add additional scopes in a custom login template?  
I have based our page on the ‘Custom Login Form’ template and need to add a Google scope not in the Social Connections list. When using the default login, this could be achieved using `connection_scope` in the URL.  
I tried adding `scope` when webAuth.authorize is called but it did not seem to make any difference, code snippet below.

````auto
<script src="https://cdn.auth0.com/js/auth0/9.14/auth0.min.js"></script>
  <script src="https://cdn.auth0.com/js/polyfills/1.0/object-assign.min.js"></script>
  <script>
    window.addEventListener('load', function() {

      var config = JSON.parse(
        decodeURIComponent(escape(window.atob('@@config@@')))
      );

      var leeway = config.internalOptions.leeway;
      if (leeway) {
        var convertedLeeway = parseInt(leeway);
      
        if (!isNaN(convertedLeeway)) {
          config.internalOptions.leeway = convertedLeeway;
        }
      }

      var params = Object.assign({
        overrides: {
          __tenant: config.auth0Tenant,
          __token_issuer: config.authorizationServer.issuer
        },
        domain: config.auth0Domain,
        clientID: config.clientID,
        redirectUri: config.callbackURL,
        responseType: 'code'
      }, config.internalOptions);

      var webAuth = new auth0.WebAuth(params);
      var databaseConnection = 'Username-Password-Authentication';
      var captcha = webAuth.renderCaptcha(
        document.querySelector('.captcha-container')
      );

      function login(e) {
        e.preventDefault();
        var button = this;
        var username = document.getElementById('email').value;
        var password = document.getElementById('password').value;
        button.disabled = true;
        webAuth.login({
          realm: databaseConnection,
          username: username,
          password: password,
          captcha: captcha.getValue()
        }, function(err) {
          if (err) displayError(err);
          button.disabled = false;
        });
      }

      function signup() {
        var button = this;
        var email = document.getElementById('email').value;
        var password = document.getElementById('password').value;

        button.disabled = true;
        webAuth.redirect.signupAndLogin({
          connection: databaseConnection,
          email: email,
          password: password,
          captcha: captcha.getValue()
        }, function(err) {
          if (err) displayError(err);
          button.disabled = false;
        });
      }

      function loginWithGoogle() {
        webAuth.authorize({
          connection: 'google-oauth2'
        }, function(err) {
          if (err) displayError(err);
        });
      }
  
      function displayError(err) {
        captcha.reload();
        var errorMessage = document.getElementById('error-message');
        errorMessage.innerHTML = err.description;
        errorMessage.style.display = 'block';
      }

      document.getElementById('btn-google').addEventListener('click', loginWithGoogle);
    });
  </script>```
````

---

<div class="post-metadata">

**Author:** ![stephanie.chamblee](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/stephanie.chamblee/32/26087_2.png) [@stephanie.chamblee](https://community.auth0.com/u/stephanie.chamblee)\
**Post date:** [January 8, 2021, 6:51pm UTC](https://community.auth0.com/t/additional-scopes-in-a-custom-login-page/55889/3 "2021-01-08T18:51:31Z")

</div>

Hi @mark.hall,

I’m doing some research on this now!

> [@mark.hall](#):
>
> I have based our page on the ‘Custom Login Form’ template and need to add a Google scope not in the Social Connections list.

Just to makes sure I understand, you are wanting to add a scope not in this list of permissions, correct:

 ![google-scopes](https://global.discourse-cdn.com/auth0/original/3X/e/0/e0afc259d28f3f3f12c4c42bb74e524ec778130f.png)

Which scope(s) are you needing to add?

Thanks,

Stephanie

---

<div class="post-metadata">

**Author:** ![mark.hall](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/mark.hall/32/12776_2.png) [@mark.hall](https://community.auth0.com/u/mark.hall)\
**Post date:** [January 8, 2021, 9:23pm UTC](https://community.auth0.com/t/additional-scopes-in-a-custom-login-page/55889/4 "2021-01-08T21:23:31Z")

</div>

One is a Google drive one (just this one [https://www.googleapis.com/auth/drive.metadata.readonly](https://www.googleapis.com/auth/drive.metadata.readonly) - we had to get approval from Google, if we request any additional ones at login it flags a warning) and Google Classroom scope, which is not in the list.

Previous with the standard non-customised login, this was added using `connection_scope=https://www.googleapis.com/auth/drive.metadata.readonly` as a query param when calling the authorize endpoint - my question is how can this be achieved with the custom login page?

---

<div class="post-metadata">

**Author:** ![stephanie.chamblee](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/stephanie.chamblee/32/26087_2.png) [@stephanie.chamblee](https://community.auth0.com/u/stephanie.chamblee)\
**Post date:** [January 11, 2021, 2:13pm UTC](https://community.auth0.com/t/additional-scopes-in-a-custom-login-page/55889/5 "2021-01-11T14:13:07Z")

</div>

In order to configure your Google social connection to request the additional scopes, you can use the Management API to override the scopes configured in the dashboard using the [options.upstream\_params](https://auth0.com/docs/connections/pass-parameters-to-idps) property.

To do this, request a PATCH to the [/api/v2/connections/{the\_connection\_id}](https://auth0.com/docs/api/management/v2#!/Connections/patch_connections_by_id) endpoint, with a payload like this:

_Note: Changes to the ‘options’ object in the JSON will overwrite all the existing options._  
_To get the connection ID, you can use the [/api/v2/connections](https://auth0.com/docs/api/management/v2#!/Connections/get_connections) endpoint_

```auto
{
  "options": {
    ...[the full options object as it is right now]..,
    "upstream_params": {
     "scope": { 
       "value":"email profile https://www.googleapis.com/auth/drive.metadata.readonly https://www.googleapis.com/auth/classroom.courses.readonly"
    }
}

```

Setting the “options.scope” property will override the permissions that are configured in the connection settings in the dashboard. Be sure to keep “email profile” in the scopes since those are required for authentication.

Once the social connection is configured to request the correct scopes, no changes should be required for your custom login page.

Let me know if you have additional questions!

Stephanie

---

<div class="post-metadata">

**Author:** ![mark.hall](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/mark.hall/32/12776_2.png) [@mark.hall](https://community.auth0.com/u/mark.hall)\
**Post date:** [January 11, 2021, 5:18pm UTC](https://community.auth0.com/t/additional-scopes-in-a-custom-login-page/55889/6 "2021-01-11T17:18:52Z")

</div>

Thanks, Stephanie - will this show in the GUI once done?

---

<div class="post-metadata">

**Author:** ![stephanie.chamblee](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/stephanie.chamblee/32/26087_2.png) [@stephanie.chamblee](https://community.auth0.com/u/stephanie.chamblee)\
**Post date:** [January 11, 2021, 5:22pm UTC](https://community.auth0.com/t/additional-scopes-in-a-custom-login-page/55889/7 "2021-01-11T17:22:26Z")

</div>

The additional scopes won’t show up in the dashboard, but you can make sure they are configured by calling [GET](https://auth0.com/docs/api/management/v2?_ga=2.97043928.674888892.1610366706-1595415333.1607347674#!/Connections/get_connections_by_id)[/api/v2/connections/{id}](https://auth0.com/docs/api/management/v2?_ga=2.97043928.674888892.1610366706-1595415333.1607347674#!/Connections/get_connections_by_id).

You should see the scopes in the `upstream_params` property in the response.

---

<div class="post-metadata">

**Author:** ![mark.hall](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/mark.hall/32/12776_2.png) [@mark.hall](https://community.auth0.com/u/mark.hall)\
**Post date:** [January 13, 2021, 11:39am UTC](https://community.auth0.com/t/additional-scopes-in-a-custom-login-page/55889/10 "2021-01-13T11:39:35Z")

</div>

For anyone else reading this, I also added `access_type=offline` in the same way

```json
{
  "options": {
    ...[the full options object as it is right now]..,
		"upstream_params": {
			"scope": {
				"value": "email profile https://www.googleapis.com/auth/drive.metadata.readonly"
			},
			"access_type": {
			   "value":"offline"
			}
		}
}

```

And also, if using curl to do this, don’t forget to set Content-Type: application/json `-H "Content-Type: application/json"`

---

<div class="post-metadata">

**Author:** ![stephanie.chamblee](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/stephanie.chamblee/32/26087_2.png) [@stephanie.chamblee](https://community.auth0.com/u/stephanie.chamblee)\
**Post date:** [January 13, 2021, 12:42pm UTC](https://community.auth0.com/t/additional-scopes-in-a-custom-login-page/55889/11 "2021-01-13T12:42:58Z")

</div>

Thanks for sharing the solution for offline access!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [January 28, 2021, 12:43pm UTC](https://community.auth0.com/t/additional-scopes-in-a-custom-login-page/55889/12 "2021-01-28T12:43:04Z")

</div>

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