- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2016 09:59 PM
I managed to access the Rest Api with Basic authentication with username and password.
Now I am trying to access the Rest Api with OAuth.
I was referring to http://http//wiki.servicenow.com/index.php?title=Generating_OAuth_Tokens#API_Request_Parameters&gsc....
This is the format of the POST message,
Host: devxxxxx.service-now.com
Accept: application/json
Content-Type: application/json
Authorization: Basic YWRtaW46Q0BycjBsMTIz
Cache-Control: no-cache
Content-Type: application/x-www-form-urlencoded
Url Encoded body:
grant_type=password&client_id=xxxxxx&client_secret=xxxxxx&username=admin&username=xxxxxx
I tried both encoded body and body without encoding, it gives the same result.
Response
{
"error": "server_error",
"error_description": "access_denied"
}
Am I missing something here? Doesn't the "admin" user has privileges to perform this operation and acquire tokens?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2016 10:15 PM
Ok, two things,
1. Mistake,
grant_type=password&client_id=xxxxxx&client_secret=xxxxxx&username=admin&username=xxxxxx
SHOULD BE,
grant_type=password&client_id=xxxxxx&client_secret=xxxxxx&username=admin&password=xxxxxx
2. For this request you should not have the Authorization Header. I removed the Basic Authorization header. it's working now.
Recap,
Using POSTMAN,
Make sure the endpoint is "https://instance-now.com/oauth_token.do "
Headers:
Accept: application/json
Body (x-www-form-urlencoded)
grant_type : password
client_id: xxxxxx
client_secret: xxxxxxx
username: username_01
password: password_01
Hope this will help someone....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2016 10:08 PM
Also I forgot to mention that it's posting to /oauth_token.do endpoint.
POST /oauth_token.do HTTP/1.1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2016 10:15 PM
Ok, two things,
1. Mistake,
grant_type=password&client_id=xxxxxx&client_secret=xxxxxx&username=admin&username=xxxxxx
SHOULD BE,
grant_type=password&client_id=xxxxxx&client_secret=xxxxxx&username=admin&password=xxxxxx
2. For this request you should not have the Authorization Header. I removed the Basic Authorization header. it's working now.
Recap,
Using POSTMAN,
Make sure the endpoint is "https://instance-now.com/oauth_token.do "
Headers:
Accept: application/json
Body (x-www-form-urlencoded)
grant_type : password
client_id: xxxxxx
client_secret: xxxxxxx
username: username_01
password: password_01
Hope this will help someone....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-27-2016 09:12 AM
Thanks, Dhanuka. That was enormously helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2017 12:18 AM
This is not working for AD/LDAP integrated credential, Please advice