# How to generate AWX Oauth2 token via API for social authenticated user

**URL:** <https://forum.ansible.com/t/how-to-generate-awx-oauth2-token-via-api-for-social-authenticated-user/38288>\
**Category:** AWX Project\
**Tags:** awx\
**Created:** [August 2, 2023, 2:09pm UTC](https://forum.ansible.com/t/how-to-generate-awx-oauth2-token-via-api-for-social-authenticated-user/38288 "2023-08-02T14:09:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ahmed](https://avatars.discourse-cdn.com/v4/letter/a/8c91f0/32.png) [@ahmed](https://forum.ansible.com/u/ahmed)\
**Post date:** [August 2, 2023, 2:09pm UTC](https://forum.ansible.com/t/how-to-generate-awx-oauth2-token-via-api-for-social-authenticated-user/38288/1 "2023-08-02T14:09:12Z")

</div>

Hi everyone,

How can I generate a Oauth2 token via API for users authenticated with SAML or OIDC

Thanks.

---

<div class="post-metadata">

**Author:** ![AWX\_Project](https://avatars.discourse-cdn.com/v4/letter/a/eada6e/32.png) [@AWX\_Project](https://forum.ansible.com/u/AWX_Project)\
**Post date:** [August 7, 2023, 1:59pm UTC](https://forum.ansible.com/t/how-to-generate-awx-oauth2-token-via-api-for-social-authenticated-user/38288/2 "2023-08-07T13:59:30Z")

</div>

Hi Ahmed,

For security reasons, we default to not allowing external users to create OAuth2 tokens. However, that can be enabled. Quote from the docs below:

_The **Allow External Users to Create Oauth2 Tokens** (ALLOW\_OAUTH2\_FOR\_EXTERNAL\_USERS in the API) setting is disabled by default. External users refer to users authenticated externally with a service like LDAP, or any of the other SSO services. This setting ensures external users cannot create their own tokens. If you enable then disable it, any tokens created by external users in the meantime will still exist, and are not automatically revoked._

Hopefully this helps,  
AWX Team

---

<div class="post-metadata">

**Author:** ![AWX\_Project](https://avatars.discourse-cdn.com/v4/letter/a/eada6e/32.png) [@AWX\_Project](https://forum.ansible.com/u/AWX_Project)\
**Post date:** [August 7, 2023, 2:01pm UTC](https://forum.ansible.com/t/how-to-generate-awx-oauth2-token-via-api-for-social-authenticated-user/38288/3 "2023-08-07T14:01:34Z")

</div>

This was the doc like for that:

- [https://docs.ansible.com/automation-controller/latest/html/administration/oauth2\_token\_auth.html](https://docs.ansible.com/automation-controller/latest/html/administration/oauth2_token_auth.html)

Also, it is possible to create an oauth2 token from the command-line, here are the docs for that:

- [https://docs.ansible.com/automation-controller/latest/html/administration/tower-manage.html#create-oauth2-token](https://docs.ansible.com/automation-controller/latest/html/administration/tower-manage.html#create-oauth2-token)

Thanks,  
AWX Team
