Token Generation

rna
Kilo Explorer

I am trying to generate the access token for an application which I have deployed over serviceNow,

Referred the link: http://wiki.servicenow.com/index.php?title=REST_API

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

Request Body:

{"grant_type":"password","client_id":"33eb1705c75f3154400b1237989343b5","client_secret":4gE[IT#5qk,

"username":"UserName",

"password":"Password"}

Response:

        Status Code: 401 Unauthorized

        {

            "error": "server_error",

            "error_description": "access_denied"

        }

Am I missing anything?

20 REPLIES 20

Hi,


Are you able to crack it, I am also facing the same issue with generating token using demo instances, getting the below response



Status Code: 401 Unauthorized


        {


            "error": "server_error",


            "error_description": "access_denied"


        }



Thanks and regards,


Venki


silas1
ServiceNow Employee
ServiceNow Employee

Venki,



I would double-check that the client_id and client_secret you're using are correct. Go to "Application Registry" module under System OAuth and create a client if needed, then use those credentials in your request.


Hi Smith,



I checked that again and yes it is correct..does the demoxxx instances allows us to generate tokens or do we need to have our own instances. Because i tried with different instances demo002,demo005 and in all it is the same result "401 Unauthorized".



has anyone succeeded in generating tokens through the rest api call using the demo instances.



Thanks and regards,


venki


billytedder
Giga Contributor

I am having the same issue so has anyone found a solution to this issue? My plans are to create an incident in ServiceNow from a SharePoint 2013 workflow and I use the "Advanced Rest Client" app in Chrome to help me test my REST calls. I have followed the wiki procedures for setting up OAuth, OAuth with REST, and the OAuth plugin is active. The funny thing is even if I do not include the request body then I still get the same access denied error but I would expect a different error since the body is missing. Is there something else that has to enabled in ServiceNow? Thanks.


silas1
ServiceNow Employee
ServiceNow Employee

Billy, can you post a sanitized version of the HTTP request you're making? It's hard to help otherwise.