cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Rishan
New Member

Bearer Tokens in Custom Connector

I'm trying to create a Custom Connector to an API endpoint that requires bearer tokens in the header for authentication. 

 

connector-header.PNG

 

In my Flow, I use a HTTP action to get a token, store it in a variable, and then pass it to my connector in the Authorization header. However, I always receive an Unauthorized error.

flow-error.PNG

 

 

 

 

 

I receive this error when I test the connector on the custom connector test page:

 

{
"status": 400,
"source": "https://power-te-westus-1.azurewebsites.net:443/tokens/msmanaged-na/eum.2Dcreategroup.5F058fd1eee2b36bb6.5Fde5addbef9cce72c/shared-eum.2dcreateg-f412c0af-e8aa-49d6-9d10-76928018c41b/exchange",
"message": "Error from token exchange: Bad authorization token. Could not find identity for access token."
}

 

 

 

 

However, it succeeds when I use a HTTP action to make a call to the same endpoint as my custom connector. I use the same bearer token in the authorization header.flow-success.png

 

 

 

Is there a way I can get this to work as a Custom Connector?

1 ACCEPTED SOLUTION

Accepted Solutions
v-yamao-msft
Community Support
Community Support

Hi @Rishan,

 

Please take this thread for a reference. You will be able to pass your bearer token to the API successfully by the following steps:

  1. On the Security tab, select "API Key" for the Authentication type
  2. For "Parameter Label" put whatever you want someone to see when they are creating a Connection off of this Connector...I used "API Key"
  3. "Parameter Name" should be "Authorization" (no quotes)
  4. For "Parameter Location", select "Header"
  5. When you create a Connection off of this Connector, you'll be prompted for your "API Key" (or whatever you used for step 2 above)
  6. Enter "Bearer YOUR_BEARER_TOKEN_VALUE" (no quotes)

 

Please check the thread link for more details:

https://powerusers.microsoft.com/t5/Connecting-To-Data/Authorization-Bearer-in-Header-Custom-Connect...

 

 

Best regards,

Mabel Mao

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
v-yamao-msft
Community Support
Community Support

Hi @Rishan,

 

Please take this thread for a reference. You will be able to pass your bearer token to the API successfully by the following steps:

  1. On the Security tab, select "API Key" for the Authentication type
  2. For "Parameter Label" put whatever you want someone to see when they are creating a Connection off of this Connector...I used "API Key"
  3. "Parameter Name" should be "Authorization" (no quotes)
  4. For "Parameter Location", select "Header"
  5. When you create a Connection off of this Connector, you'll be prompted for your "API Key" (or whatever you used for step 2 above)
  6. Enter "Bearer YOUR_BEARER_TOKEN_VALUE" (no quotes)

 

Please check the thread link for more details:

https://powerusers.microsoft.com/t5/Connecting-To-Data/Authorization-Bearer-in-Header-Custom-Connect...

 

 

Best regards,

Mabel Mao

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Thank you, that got my flow to complete successfully!

flow-success2.PNG

@Rishan , that looks like a good solution.  Sorry to resurrect an old post.  I've been able to get to the point where I initialize the bearer token variable , but have been unable to provide it as a value in the Authorization header.  Were you able to do that, or does the token go elsewhere in the custom connector that you're using?

Hi @MarkIannucci , 

 

Please refer to the screenshot below. You don't even have to initialise a variable for the token: 

authee.png

Expression used : 

body('HTTP_Request_Name')['result']

Replace the 'HTTP_Request_Name' with the name of the action in which you are sending the authentication request. 

 

Hope this Helps!

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

 

 

 

Thank you this was a huge help!

Hi @yashag2255 

I'm having difficulty understanding your post.  I'm retrieving a token and storing it in a variable.  I don't understand how this populates the 'Authorization' parameter in the custom connector.  How does get the bearer token?

Helpful resources

Announcements
MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Users online (99,581)