Getting authentication token through mid server

mehdifaraj5
Giga Contributor

Hello Dear,

we have an anssible application installed in internal server and we want to get token from OAuth 2.0 Credential by clicking on "get OAuth Token" through mid server but it didn't work.

Regards,

Mehdi FARAJ

 

1 ACCEPTED SOLUTION

Goran WitchDoc
ServiceNow Employee
ServiceNow Employee

Hi Mehdi,

As far as I know, it isn't possible to do that through the MID Server. Take a look here: Outbound REST authentication | ServiceNow Docs

"OAuth 2.0 can be used only with messages that are not configured to use a MID Server. You cannot send OAuth 2.0 authenticated messages through a MID Server."

 

//Göran
Feel free to connect:
LinkedIn
Subscribe to my YouTube Channel
or look at my Book: The Witch Doctor's Guide To ServiceNow

View solution in original post

7 REPLIES 7

Goran WitchDoc
ServiceNow Employee
ServiceNow Employee

Hi Mehdi,

As far as I know, it isn't possible to do that through the MID Server. Take a look here: Outbound REST authentication | ServiceNow Docs

"OAuth 2.0 can be used only with messages that are not configured to use a MID Server. You cannot send OAuth 2.0 authenticated messages through a MID Server."

 

//Göran
Feel free to connect:
LinkedIn
Subscribe to my YouTube Channel
or look at my Book: The Witch Doctor's Guide To ServiceNow

I realize you are just relaying information here but how would I go about securing a REST message made through a MID server? I have an internal application that authenticates tokens granted by an internal identity provider. Am I to understand that the MID server can not be used to make authenticated calls to an internal REST service?

Julien Dumoul1
Tera Contributor

Hello, did you ever find a solution to secure with OAuth2 an internal integration from ServiceNow to a another provider ? We are in the same situation.

Best regards

steve87
Giga Contributor

Yes. What I did was to create some javascript functions to handle things like token acquisition, token caching, retrieving the client-id and clientSecret (stored in Service Now secrets) needed for token acquisition. Then I wrote another js function that wraps 

RESTMessageV2  . After doing this I was able to call my own functions from wherever I needed to like Workflows etc. It is a bit involved but it allowed me to do what I needed to do and maintain control.