Skip to main content

Notifications

Community site session details

Community site session details

Session Id : zFPyIkNeYestikmkzHzFmy
Power Automate - Using Connectors
Answered

Bearer Tokens in Custom Connector

Like (1) ShareShare
ReportReport
Posted on 10 Aug 2018 12:37:54 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?

  • gabeng Profile Picture
    32 on 19 Feb 2023 at 17:28:55
    Re: Bearer Tokens in Custom Connector

    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

  • Community Power Platform Member Profile Picture
    on 14 Nov 2022 at 06:35:17
    Re: Bearer Tokens in Custom Connector

    how to override the dynamic jwt token in custom connector?

  • ronn_zw Profile Picture
    26 on 08 Sep 2022 at 08:22:27
    Re: Bearer Tokens in Custom Connector

    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

  • Jeff_Schuler Profile Picture
    17 on 01 May 2020 at 17:42:47
    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?

  • kirstenthomas18 Profile Picture
    15 on 27 Aug 2019 at 23:09:32
    Re: Bearer Tokens in Custom Connector

    Thank you this was a huge help!

  • yashag2255 Profile Picture
    24,442 Super User 2024 Season 1 on 31 May 2019 at 08:39:03
    Re: Bearer Tokens in Custom Connector

    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!

     

     

     

  • Community Power Platform Member Profile Picture
    on 30 May 2019 at 05:17:52
    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?

  • Rishan Profile Picture
    6 on 13 Aug 2018 at 13:01:44
    Re: Bearer Tokens in Custom Connector

    Thank you, that got my flow to complete successfully!

    flow-success2.PNG

  • Verified answer
    v-yamao-msft Profile Picture
    on 13 Aug 2018 at 07:13:06
    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-Connector/td-p/51541

     

     

    Best regards,

    Mabel Mao

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,743 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,089 Most Valuable Professional

Leaderboard

Featured topics

Loading started