How to send POST request to Oauth2 token endpoint?

daniel chicchon
Mega Contributor

Currently I'm trying to get an access token utilizing OAuth 2.0 using Postman. I'm following this guide here

Here is my request:

`https://myinstance.service-now.com/oauth_token.do`

My data is set to: form-data-urlencoded

{
grant_type: password,

client_id: id,

client_secret:secret,

username: username,

password:password
}

Except when I run this request, I get a 401 unauthorized response

{
"error_description":"access_denied",
"error":"server_error"
}
 
Is there somewhere I need to enable access to my token? Or is my request malformed? Any help would be appreciated.
2 REPLIES 2

Tony Chatfield1
Kilo Patron

Hi, testing in Postman I don't see an option to add the key:value pairs in the format you have above.

Otherwise using a body that is x-www-form-urlencoded with separate entries for each key:value,
the only possible issue I can see with your data is the existence of white space ' ' prefixing some values and suspect that this could be seen as part of the value string.

Appreciate your help Tony! Turns out it was my own fault and I was using the wrong user credentials and now I am able to access the endpoint.