REST API using OAuth Authenication with Single Sign-On (SSO)

billytedder
Giga Contributor

I am trying to create an incident in ServiceNow from a SharePoint 2013 workflow using OAuth to get the access token for creating the item via REST. I have followed the wiki procedures for setting up OAuth, OAuth with REST, and the OAuth plugin is active. Here is the request and the response that I get:

Rest API: https://<InstanceName>.service-now.com/oauth_token.do

Request Body:

grant_type=password&client_id={ID}&client_secret={Secret}&username={UserName}&password={Password}

Response:

      Status Code: 401 Unauthorized

      {

          "error": "server_error",

          "error_description": "access_denied"

      }

I have even encoded the secret and password but I still get the same results. I have also validated that I am using the correct client ID and secret that were set-up in ServiceNow and my password is correct. Also for the username I have tried myusername, domain\myusername, and myusername@domain.com but still no success.

In addition, when I make the request call without the request body then I still get access denied. I would expect an error message stating that the parameters are missing.

Our company uses Single Sign-On when we access ServiceNow so is there another procedure that I need to follow or is there another setting that needs to be enabled/ disabled? Thanks.

1 ACCEPTED SOLUTION

billytedder
Giga Contributor

The resolution to this issue was that the {UserName} account must have the "rest_service" role.


View solution in original post

4 REPLIES 4

billytedder
Giga Contributor

The resolution to this issue was that the {UserName} account must have the "rest_service" role.


I am trying this on Helsinki version. I added userName to rest_service role too. it says it is deprecated...



I am trying this using postman. tried both post and get methods with the url



https://dev26116.service-now.com/oauth_token.do?grant_type=password&client_id=c73d646818756600cbbbc8...



I get the response access_denied and server_error.



Oauth 2.0 plugin is enabled.   the app is registered.


vishnup
Tera Contributor

HI,


I've the same issue . Can you please help me out on this??


I also resolved my issue on Helsinki by adding the "service_api_admin" role.   Same error of access_denied and server_error.



Build name: Helsinki


Build date: 09-15-2016_0944


Build tag: glide-helsinki-03-16-2016__patch5-09-08-2016



Thanks,


Bryan