web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Bearer Tokens in Custo...
Power Automate
Unanswered

Bearer Tokens in Custom Connector

(1) ShareShare
ReportReport
Posted on by 6

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?

Categories:
I have the same question (0)
  • Verified answer
    v-yamao-msft Profile Picture
    on at

    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-Connector/td-p/51541

     

     

    Best regards,

    Mabel Mao

  • Rishan Profile Picture
    6 on at

    Thank you, that got my flow to complete successfully!

    flow-success2.PNG

  • Community Power Platform Member Profile Picture
    on at

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

  • yashag2255 Profile Picture
    24,769 Super User 2024 Season 1 on at

    Hi @Anonymous , 

     

    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!

     

     

     

  • kirstenthomas18 Profile Picture
    15 on at

    Thank you this was a huge help!

  • Jeff_Schuler Profile Picture
    17 on at

    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?

  • ronn_zw Profile Picture
    26 on at

    Hi @Rishan 

     

    My token expires every 10 mins so if l use the API key method, l won't be able to refresh the token. Is there a way to pass the token inside Flow?

    Thanks

  • Community Power Platform Member Profile Picture
    on at

    how to override the dynamic jwt token in custom connector?

  • gabeng Profile Picture
    32 on at

    I found a solution regarding expiring Bearer Tokens using Policies in Custom Connectors. Policies allow to rewrite headers.

    https://powerusers.microsoft.com/t5/Connector-Development/Creating-a-Power-Automate-custom-connector-using-Bearer-Token/m-p/2022427/highlight/true#M2193

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard