How can we programmatically create an inbound OAuth Client Credentials registry from a scoped app

ajayshrivas
Tera Contributor

Hi Community,

We are developing a scoped ServiceNow application and need to automate the setup of an inbound OAuth 2.0 Client Credentials integration as part of a setup wizard.

 

Requirement

Our application should automatically perform the following steps:

  1. Create a dedicated machine-identity user in sys_user.

  2. Assign the itil role through sys_user_has_role.

  3. Create an inbound OAuth 2.0 Client Credentials registry.

  4. Set the integration user as the OAuth Application User.

  5. Generate the Client ID and Client Secret.

  6. Associate an existing REST API/Table API authentication scope with the OAuth client.

Some of the points we done such as create user in sys_user table and assign role to that user. 

However, when we try to create an OAuth registry using GlideRecord from our scoped application, ServiceNow blocks the operation.

 

Error encounter - "has been refused due to the api's cross-scope access policy."

Can you please suggest me any alternative way and how can i achieve this, is this possible ? 

0 REPLIES 0