Flow of OAuth Process (ServiceNow is using a third party OAuth Provider)
What Is OAuth?
OAuth 2.0 is an authorization framework that enables applications to obtain limited access to user accounts on an HTTP service.
It works by delegating user authentication to the service that hosts the user account, and authorising third-party applications to access the user account. OAuth 2.0 focuses on client developer simplicity while providing specific authorisation flows for web applications, desktop applications, mobile phones, and living room devices. When using ServiceNow as a client resource, OAuth 2.0 lets user access instance resources through external clients by obtaining a token rather than by entering login credentials with each resource request.
How OAuth and ServiceNow works?
OAuth 2.0 lets user access instance resources through external clients by obtaining a token rather than the need to enter login credentials with each resource request.
OAuth 2.0 can be configured in the below scenarios.
- OAuth external client scenario
- OAuth provider scenario
OAuth has below grant types
- Authorization code
- Resource owner password credentials
- Client credentials
What to consider when OAuth 2.0 is configured in ServiceNow?
- Make sure the OAuth plugin is active and the OAuth activation property is set to true.
- Make sure that the grant type is matching between the client and resource systems and the same is shared with OAuth provider.
- Client ID, Client secret are shared among the systems.
- In case of Resource owner password credentials, the consumer of the resource already has the user credentials to get the access token. The same user name and password has to be provided when accessing the token from the OAuth provider.
- In Case of Authorization code grant type consumer first gets an authorization code and then uses it to get an access token.
- Make sure to fetch the refresh token once the access token has expired, reusing the access token after it has expired will result in failure.
The below two scenarios helps you to understand what type of OAuth integration you need to set up in ServiceNow.
OAuth external client scenario
In this scenario ServiceNow provides an endpoint for third-party clients to pull data from the instance. This is done by creating an OAuth API endpoint for external clients.
The above Client secret is stored as password2 type field, which is encrypted in Triple DES. User passwords, which are used to check incoming endpoint requests, are stored as a hash value in the User table in a password type field (SHA 256).
OAuth provider scenario
In this scenario, ServiceNow consumes an endpoint for third-party clients to pull data from the 3rd party.
This is done by creating connection to a third party OAuth Provider.
Written by –
Tribe – CSM