# How to map users' roles or groups from Google for use in Auth0?

**URL:** <https://community.auth0.com/t/how-to-map-users-roles-or-groups-from-google-for-use-in-auth0/133861>\
**Category:** Get Help\
**Tags:** user-profile, user-management\
**Created:** [May 10, 2024, 3:36pm UTC](https://community.auth0.com/t/how-to-map-users-roles-or-groups-from-google-for-use-in-auth0/133861 "2024-05-10T15:36:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![arilsonbarcelos](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/arilsonbarcelos/32/49596_2.png) [@arilsonbarcelos](https://community.auth0.com/u/arilsonbarcelos)\
**Post date:** [May 10, 2024, 3:36pm UTC](https://community.auth0.com/t/how-to-map-users-roles-or-groups-from-google-for-use-in-auth0/133861/1 "2024-05-10T15:36:43Z")

</div>

Hi everyone!

Is it possible to map users’ roles or groups from Google for use in Auth0?

I need users to assume the role configured on Google when logging in. A second option would be to map the user’s groups from Google as roles in Auth0.

I created an post-login Action to retrieve values from the ‘event.user.identities’ object, but there are no values for roles or groups.

By the way, I’m using Enterprise authentication and I’ve activated the Groups option in Extended Attributes, but I’m getting the error “Unable to get groups: unauthorized”.

Thank you for helping!

---

<div class="post-metadata">

**Author:** ![marcelina.barycka](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/marcelina.barycka/32/56162_2.png) [@marcelina.barycka](https://community.auth0.com/u/marcelina.barycka)\
**Post date:** [May 14, 2024, 11:12am UTC](https://community.auth0.com/t/how-to-map-users-roles-or-groups-from-google-for-use-in-auth0/133861/3 "2024-05-14T11:12:18Z")

</div>

Hey @arilsonbarcelos !

I am checking the options here, and for now, I can share the feedback regarding:

> [@arilsonbarcelos](#):
>
> By the way, I’m using Enterprise authentication and I’ve activated the Groups option in Extended Attributes, but I’m getting the error “Unable to get groups: unauthorized”.

Your client application, on the user’s behalf, can only access scopes requested during the authentication.

Can you please check if the /authorize request that your application sends to auth0 contains the `scope` query parameter with Google’s group scope?  
If I’m not mistaken, the scope for Google Groups membership is `https://apps-apis.google.com/a/feeds/groups/.`

Thanks,  
Marcelina

---

<div class="post-metadata">

**Author:** ![arilsonbarcelos](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/arilsonbarcelos/32/49596_2.png) [@arilsonbarcelos](https://community.auth0.com/u/arilsonbarcelos)\
**Post date:** [May 15, 2024, 1:25pm UTC](https://community.auth0.com/t/how-to-map-users-roles-or-groups-from-google-for-use-in-auth0/133861/4 "2024-05-15T13:25:50Z")

</div>

Hi @marcelina.barycka! Thank you for your reply!

I’m using this simple app for testing: [GitHub - auth0-samples/auth0-python-web-app: Auth0 Integration Samples for Python and Flask Web Applications](https://github.com/auth0-samples/auth0-python-web-app)  
The only possibility to set up scopes is in the part of code below, and I’ve tried to put ‘groups’ there , without success.

```auto
oauth.register(
    "auth0",
    client_id=env.get("AUTH0_CLIENT_ID"),
    client_secret=env.get("AUTH0_CLIENT_SECRET"),
    client_kwargs={
        "scope": "openid profile email",
    },
    server_metadata_url=f'https://{env.get("AUTH0_DOMAIN")}/.well-known/openid-configuration',
)

```

Thank you again for your help!

---

<div class="post-metadata">

**Author:** ![marcelina.barycka](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/marcelina.barycka/32/56162_2.png) [@marcelina.barycka](https://community.auth0.com/u/marcelina.barycka)\
**Post date:** [May 16, 2024, 2:00pm UTC](https://community.auth0.com/t/how-to-map-users-roles-or-groups-from-google-for-use-in-auth0/133861/5 "2024-05-16T14:00:57Z")

</div>

Hi @arilsonbarcelos ,

Did you include the whole string `https://apps-apis.google.com/a/feeds/groups/`?  
Like this:

```auto
oauth.register(
    "auth0",
    client_id=env.get("AUTH0_CLIENT_ID"),
    client_secret=env.get("AUTH0_CLIENT_SECRET"),
    client_kwargs={
        "scope": "openid profile email https://apps-apis.google.com/a/feeds/groups/" 
    },
    server_metadata_url=f'https://{env.get("AUTH0_DOMAIN")}/.well-known/openid-configuration',
)

```

---

<div class="post-metadata">

**Author:** ![marcelina.barycka](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/marcelina.barycka/32/56162_2.png) [@marcelina.barycka](https://community.auth0.com/u/marcelina.barycka)\
**Post date:** [May 16, 2024, 2:42pm UTC](https://community.auth0.com/t/how-to-map-users-roles-or-groups-from-google-for-use-in-auth0/133861/6 "2024-05-16T14:42:49Z")

</div>

I was looking further into it @arilsonbarcelos , and actually the upstream IdP’s scopes should be under:

```auto
“upstream_params”: {"connection_scope": {
        "value": "https://www.googleapis.com/........"
      }}

```

> **[Add Scopes/Permissions to Call Identity Provider APIs](https://auth0.com/docs/authenticate/identity-providers/adding-scopes-for-an-external-idp)**
>
> Describes how to add scopes to your IdP connection.

Also, make sure that the application registered on the Google side has appropriate scopes allowed.  
We have a Knowledge Solution for analogic use-case, maybe you find it helpful for general steps: [Accessing Additional Scopes in Google Social Connection](https://community.auth0.com/t/accessing-additional-scopes-in-google-social-connection/118902)

---

<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:** [June 3, 2024, 6:34am UTC](https://community.auth0.com/t/how-to-map-users-roles-or-groups-from-google-for-use-in-auth0/133861/7 "2024-06-03T06:34:03Z")

</div>

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