The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Access denied with Oauth2

lucaburgazzoli
Mega Contributor

Hello, 

I'm trying to use OAuth2 to access ServiceNow through its REST APIs and I've followed the guides here:

  1. https://docs.servicenow.com/bundle/paris-platform-administration/page/administer/security/reference/r_OAuthAPIRequestParameters.html
  2. https://community.servicenow.com/community?id=community_blog&sys_id=56086e4fdb9014146064eeb5ca961957

But I'm constantly getting HTTP 401 unauthorized, what should I check ?

1 ACCEPTED SOLUTION

Hi,

Did you follow the steps properly as mentioned in blog?

Also are you using correct username and password combination

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

10 REPLIES 10

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

Thanks for going through my blog.

Error 401 means incorrect username and password

Are you getting this error when obtaining the Access token for the first time?

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Ankur Bawiskar
Tera Patron
Tera Patron

@lucaburgazzoli 

Are you able to get the OAuth access token with the non-admin user session?

The ACL on the oauth_credential table might be causing this issue. Try adding a read ACL on the table and provide the role who needs this access to call and you should be able to test it.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

lucaburgazzoli
Mega Contributor
It turn out that the issue was that I didn't set


Content-Type: application/x-www-form-urlencoded


When adding it, then the call succeeded and I'm able to my token (the error message does not really help understanding the issue)

Hi,

Did you follow the steps properly as mentioned in blog?

Also are you using correct username and password combination

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader