I'm trying to create a Custom Connector to an API endpoint that requires bearer tokens in the header for authentication.
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.
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.
Is there a way I can get this to work as a Custom Connector?
I found a solution regarding expiring Bearer Tokens using Policies in Custom Connectors. Policies allow to rewrite headers.
how to override the dynamic jwt token 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
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?
Thank you this was a huge help!
Hi @Anonymous ,
Please refer to the screenshot below. You don't even have to initialise a variable for the token:
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!
@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?
Thank you, that got my flow to complete successfully!
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:
Please check the thread link for more details:
Best regards,
Mabel Mao
WarrenBelz
146,743
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
66,089
Most Valuable Professional