Get started with OAuth Applications
You can access the OAuth Applications page from the navigation panel by selecting . From there you can view, create, sort and search for applications currently managed by Ansible Automation Platform and automation controller.
If no applications exist, you can create one by clicking .
Application functions
Several OAuth 2 utilities are available for authorization, token refresh, and revoke. You can specify the following grant types when creating an application:
- Password
- This grant type is ideal for users who have native access to the web application and must be used when the client is the resource owner.
- Authorization code
- This grant type should be used when access tokens must be issued directly to an external application or service.
You can only use the authorization code type to acquire an access token when using an application. When integrating an external web application with Ansible Automation Platform, that web application might need to create OAuth2 tokens on behalf of users in that other web application. Creating an application in the platform with the authorization code grant type is the preferred way to do this because:
- This allows an external application to obtain a token from Ansible Automation Platform for a user, using their credentials.
- Compartmentalized tokens issued for a particular application enables those tokens to be easily managed. For example, revoking all tokens associated with that application without having to revoke all tokens in the system.
Refresh an access token after expiration
You can use a refresh token to request a new access token after the original token expires.
About this task
The default expiration for OAuth2 access tokens is 31,536,000 seconds (1 year). You can configure this value in the OAUTH2_PROVIDER settings in etc/ansible-automation-platform/gateway/settings.py.
When an access token expires, use the original refresh token to request a new access token without re-authorizing.
Procedure
What to do next
REFRESH_TOKEN_EXPIRE_SECONDS setting in OAUTH2_PROVIDER in /etc/ansible-automation-platform/gateway/settings.py.
Configure the OAuth access token lifetime on OpenShift Container Platform
On an operator-based installation, set the OAuth access token lifetime in the AnsibleAutomationPlatform custom resource so platform gateway applies it across reconciliations.
Before you begin
- Cluster access to edit the
AnsibleAutomationPlatformcustom resource (CR).
About this task
Set the OAuth access token lifetime in the AnsibleAutomationPlatform CR by using spec.extra_settings.
Do not edit the operator-managed platform gateway settings Secret directly. The operator regenerates that Secret from the CR, so manual edits are lost on the next reconciliation.
Procedure
What to do next
- Changing the lifetime affects only newly created tokens. Existing tokens keep their original expiration.
- Avoid extremely short lifetimes. A short lifetime can affect the operator service-account OAuth token if that token is recreated after the setting is applied.