- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-06-2021 02:41 PM
Hello,
I am trying to access the Microsoft Graph API via REST step in action designer but am having trouble passing the token into my header. I have already done the following:
- Registered my application in Azure and confirmed app is assigned the appropriate roles and permissions.
- Registered this within ServiceNow application registry and defined oAuth entity profiles and scopes. (default and offline_access)
- It's worth noting that I set the Default grant type as Resource owner password credentials so I can authenticate and post to endpoints under a service account. After much research, this is the best solution for my requirements.
- Created a new credential alias with a connection and credential. Within that credential, I am able to successfully "Get oAuth token". The expiration date is a time far into the future. I confirmed this refresh token exists in oauth_credential table.
I've spent many hours to be sure the parts above are set up correctly. I can successfully the endpoints I need to use via an outbound REST message. My problem is when I try to call this API via REST Step in an action within Flow Designer.
As you can see in the setup below, I have it set up under my connection alias that has the oauth token. I am using the exact script listed on the Microsoft website to post to teams. (Please note, I do not want to use the OOTB teams actions for functionality reasons)
When I test this action, I get the error shown below:
{
"error": {
"code": "InvalidAuthenticationToken",
"message": "Access token is empty.",
"innerError": {
"date": "2021-04-06T20:22:11",
"request-id": "24ab03xxx",
"client-request-id": "24abxxxxx"
} }}
After rereading the Microsoft documentation, I noticed the header "Authorization: Bearer {code}" Is required. How can I obtain the oAuth token from my connection alias to put into this header? It doesn't seem like a simple table lookup since it is encrypted in the oauth_credential table. I saw this this Flow Designer & IntegrationHub Lab and it looks like I may need to set up something similar to the "Connection Attribute" they set up within the Alias so that I can have a data pill of the token to drag it into my header in REST step. I have no idea where to go from here or how to grab the data after running the "get oauth token" link. Where do I go from here to be able to transfer the oAuth token from my alias to the REST step in Action? What am I doing wrong?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2021 12:35 AM
Hi,
You should be able to use the credential value like this. Remember to put in "Bearer " first since the value only holds the token and not "Bearer ". also don't forget the whitespace after it as well.
//Göran
Feel free to connect:
LinkedIn
Subscribe to my YouTube Channel
or look at my Book: The Witch Doctor's Guide To ServiceNow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2021 12:35 AM
Hi,
You should be able to use the credential value like this. Remember to put in "Bearer " first since the value only holds the token and not "Bearer ". also don't forget the whitespace after it as well.
//Göran
Feel free to connect:
LinkedIn
Subscribe to my YouTube Channel
or look at my Book: The Witch Doctor's Guide To ServiceNow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2021 06:13 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2021 06:28 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-18-2024 12:45 PM
Hello,
I am trying to set this up for a JAMF integration since we are not licensed for the service graph connector and the spoke does not support bearer tokens.
When attempting to add the credential value, it returns a blank value.
I have also tried entering the API key directly from the oauth record however this returns an invalid token as the token is updated during the rest call.
Any idea why the credential would be returning no value?