cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
Highlighted
Community Support
Community Support

Re: Bearer Tokens in Custom Connector

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
Highlighted
Community Support
Community Support

Re: Bearer Tokens in Custom Connector

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

Highlighted
New Member

Re: Bearer Tokens in Custom Connector

Thank you, that got my flow to complete successfully!

flow-success2.PNG

Highlighted
Frequent Visitor

Re: Bearer Tokens in Custom Connector

@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?

Highlighted
Dual Super User
Dual Super User

Re: Bearer Tokens in Custom Connector

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!

 

 

 

Highlighted
Frequent Visitor

Re: Bearer Tokens in Custom Connector

Thank you this was a huge help!

Highlighted
Frequent Visitor

Re: Bearer Tokens in Custom Connector

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
firstImage

Now Live: Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

Users online (6,018)