OAuth 401 even with token?

asampson
Mega Contributor

Hey SN,

 

We're trying to use OAuth to access our QA Environment through REST calls. We're able to recieve a token but when we try to access tables with that token we're getting a 401 returned, access denied.  

 

I know I have ACLs on the tables we're querying, and I even disabled them, but we're still getting a 401 issue.

 

Any reason why this would happen?

 

Thanks!

1 ACCEPTED SOLUTION

asampson
Mega Contributor

Looks like I have to pass in a username and a password when requesting a token. That sets the access for the token.



In my original headers I was hoping to use a grant_type of client_credentials to get away from any user account management. We use SSO so passwords are not locally stored in user accounts. For the access to work I have to make a local ServiceNow account, give it a password, and the correct role. Then I can pass in that username/password to my token generator. Instead of client_credentials I now have to use a grant_type of password.



After I get that token, I no longer get my 401 errors.


View solution in original post

7 REPLIES 7

Hi Austin,



In Headers please add the Authentication header



usually for some integrations we will encode username and password into base 64 format and provide the authentication like



Authentication         Basic (base64encoded username and password)



please try this



Thank you.


Hey Harish,



I can successfully pass in Authentication with basic user credentials and log in just fine. But the goal is to use OAuth, not basic. I tried setting the header to be Authentication Bearer <token> but that didn't work either.



What's next?


asampson
Mega Contributor

Looks like I have to pass in a username and a password when requesting a token. That sets the access for the token.



In my original headers I was hoping to use a grant_type of client_credentials to get away from any user account management. We use SSO so passwords are not locally stored in user accounts. For the access to work I have to make a local ServiceNow account, give it a password, and the correct role. Then I can pass in that username/password to my token generator. Instead of client_credentials I now have to use a grant_type of password.



After I get that token, I no longer get my 401 errors.