oauth 2.0 is failing when i click on Test

Priyanka_77
Tera Contributor

I have created an outbound rest message to get the token. When i click on get oauth token it says oauth flow completed successfully.
I have selected authentication as oauth 2.0 and given all the details like client id, client secret, grant type: Client credentials.


I have created POST method to get the token from the endpoint.
I am getting below error:
{"error":"invalid_request","error_description":"Missing form parameter: grant_type"}

When i give client id, client secret and grant type in the content in post method it is working fine but i have created oauth profile and content is empty but it is not working, it should ideally work.

I have also added headers like
Accept */*
Content-Type  application/x-www-form-urlencoded
User-Agent servicenow

6 REPLIES 6

Ankur Bawiskar
Tera Patron

@Priyanka_77 

what's the grant type when you did setup in ServiceNow?

share some screenshots for your OAuth config you did?

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

Hi @Ankur Bawiskar ,

 

I have created outbound rest message: Token Generation where i have selected oauth2.0 and selected the oauth profile with details in it like client id, client secret, token url,etc.
So, whenever i click on get oauth token, it sayd oauth flow completed successfully.
Now, there is one POST http method created for this outbound message which hits the endpoint url and gets the access token. SO, below are the configurations:
Authentication : Inherit from parent
HTTP headers:
Accept */*
Content-Type  application/x-www-form-urlencoded
User-Agent servicenow

Now, when i click on Test it shows below error:
{"error":"invalid_request","error_description":"Missing form parameter: grant_type"}

But the oauth profile selected already has grant type: client credentials, then why it is showing me this error.

So, i tried to send the client credentials in the content explicitly:
client_id=${client_id}&client_secret=${client_secret}&grant_type=client_credentials
It is working when i explicitly give this in the content but my point is we have selected oauth profile, it should work without giving this content but it is not working.




 

@Priyanka_77 

for grant_type as client credentials share the OAuth registry you configured

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

@Ankur Bawiskar 
Below are the configurations that i did.
I have given client id, client secret,
Default Grant type: CLient credentials
token url, redirect url,send credentials: in request body.