failed authenticating using authentication code

lital_halawi
Kilo Explorer

hey,

I try authenticating through Oauth to my instance using authentication code.

I fail with 401 unauthorized

{

      "error_description": "access_denied",

      "error": "server_error"

}

my flow:

I configured my instance to use my authentication server.

then - I follow https://dev12427.service-now.com/oauth_auth.do?response_type=code&client_id=30b47d885e030300230439da...

click on allow - and I see a new token is created on manage tokens (limited for 1 minute for an unknown reason)

when I try to use this token to authenticate I fail.

my request:

POST to: https://dev12427.service-now.com/oauth_token.do

client_id : ...

client_secret: ...

Conten-type: application/x-www-form-urlencoded

grant_type: code

code: the authentication code I got

what am I doing wrong

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Lital,



While consuming servicenow endpoint and using OAuth only following grant types are supported.


password or refresh_token.



If you want to check complete details on this read my post here.


https://community.servicenow.com/thread/264379



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


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

Hey Ankur,


I try following these guides:


OAuth authorization code grant flow



OAuth support for authorization code flow



Example: authcode flow: ServiceNow instance as authorization server



it appears that I can configure my instance to work with oauth using authentication code


currently I try it on a dev instance.


can you help me with that?


Hi Lital,



If you are consuming Servicenow endpoint then only above 2 grant types are supported. no other way to include one more in that list.



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


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