StandardCredentialsProvider not working for non-admin users

Alexandre Freit
ServiceNow Employee
ServiceNow Employee

I created a Script Include that uses sn_cc.StandardCredentialsProvider to retrieve a given credential I need to consume a REST operation. When this script include is called by my user (e.g. through a UI Action), which has the admin role, it runs as expected. However, when the script include is called by a non-admin user, the script fails because getCredentialByID returns null. Is there a way to make this script include work for non-user admins too?

1 ACCEPTED SOLUTION

Alexandre Freit
ServiceNow Employee
ServiceNow Employee

I found a solution for this issue. Since I'm consuming the REST service using RESTMessageV2, creating a basic authentication profile and using it with the setAuthenticationProfile method enabled the script include to run when called by non-admin users.

View solution in original post

5 REPLIES 5

Alexandre Freit
ServiceNow Employee
ServiceNow Employee

I found a solution for this issue. Since I'm consuming the REST service using RESTMessageV2, creating a basic authentication profile and using it with the setAuthenticationProfile method enabled the script include to run when called by non-admin users.

SaschaWildgrube
ServiceNow Employee
ServiceNow Employee

I am running into the same problem here. Using RESTMessageV2 in this context is not an option. I really need to load the credentials and process them in the script. So how can we make sn_cc.StandardCredentialsProvider.getCredentialByID() work in a script invoked by a non-admin user?

Did you ever figure this out? Running into the same problem.

kinda. The user that triggers the operation must have read access to the credential table to make this work. Crazy but true.