cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
rpiwetz
Level: Power Up

Authorization Bearer in Header - Custom Connector

I have created a custom connector that is connecting to a vendor's API.  I have unauthenticated GET methods working, but now am working on some POSTs and am running into an issue with putting "Authorization: Bearer token_value" in the header.  Even on the unauthenticated GET calls, I can see in the request header that "Authorization: Bearer some_token_value" is already there.  I've tried setting the Header in my POST call, but then I get the error: "Message": "Error from ASE: Bad authorization header scheme".

 

I can see that the request header has my token_value and so it appears I'm not allowed to set the header that way.  What is the right way to send my "Authorization: Bearer token_value" to the API?

 

Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions
rpiwetz
Level: Power Up

Re: Authorization Bearer in Header - Custom Connector

I've figured this out by learning about making an OpenAPI document describing the interface, and creating a custom connector off of the document.

  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)

This will pass your bearer token to the API successfully.

13 REPLIES 13
alexco
Level: Powered On

Re: Authorization Bearer in Header - Custom Connector

I have the same issue, did you solve it in the meantime?

rpiwetz
Level: Power Up

Re: Authorization Bearer in Header - Custom Connector

I ended up opening a ticket with Microsoft, went back and forth with them a few times, but they never seemed to understand the issue no matter how many times I explained it, so I've had to give up for now.

kmsFG19
Level: Powered On

Re: Authorization Bearer in Header - Custom Connector

 Facing the same problem - MS should help us out here!! 

rpiwetz
Level: Power Up

Re: Authorization Bearer in Header - Custom Connector

I've figured this out by learning about making an OpenAPI document describing the interface, and creating a custom connector off of the document.

  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)

This will pass your bearer token to the API successfully.

alexco
Level: Powered On

Re: Authorization Bearer in Header - Custom Connector

Nice, I will try this. However, this doesn't work with an expiring token.

fleagle66
Level: Power Up

Re: Authorization Bearer in Header - Custom Connector

This did not work for me. Actually nothing has to this point. I've tried encoded Basic authentication with api key and bearer token but still get 401 unauthroized.

sphillips22
Level: Powered On

Re: Authorization Bearer in Header - Custom Connector

This works for me as the admin-developer. However when sharing the app with end users, it forces them to enter the API Key to use the application.

 

Is it known if there is a way to work-around this functionality?

keatklein
Level: Powered On

Re: Authorization Bearer in Header - Custom Connector

The solution provided by rpiwetz worked for me, sort of.  I did need to add an "accept:application/json" header to the defenition first though, otherwise I got a 401 error.

 

I said "sort of" above because I still cannot figure out a solution for an expiring token.  I can get this to work by population the connector with my expiring token, but then it only works for 1 hour.  Has anybody figured out a solution for an expiring token?

DMum
Level: Powered On

Re: Authorization Bearer in Header - Custom Connector

Same issue expirting token won't work with API Key. Any luck? Thank you!

OttoVoss
Level: Power Up

Re: Authorization Bearer in Header - Custom Connector

I'm facing the same challenge. Have some of you found a way to do it?

keatklein
Level: Powered On

Re: Authorization Bearer in Header - Custom Connector

I don't think it's possible if you have an expiring token.  I tried everything I could think of and never found a solution.

Highlighted
Dinesh
Level: Powered On

Re: Authorization Bearer in Header - Custom Connector

I found an interesting way to do this. In my case the token expires in 24 hours. So I create a seperate flow which runs every 24 hours to update the new token. Steps in the new flow

  1. Trigger to run every 24 hours
  2. HTTP request to the Authentication endpoint to generate new token
  3. Create connection action in Flow management to create a new connection for the custom connector with the token generated in the previous step
  4. Get Flow action to fetch the details of the actual flow
  5. Update Flow action to update the new connection to the flow

Now every 24 hours new connection is created and used by the flow. It works for me. But i would like to have a Edit connection action which would be more helpful. Please vote for this idea.

https://powerusers.microsoft.com/t5/Flow-Ideas/Edit-connection-in-Flow-management-connector/idi-p/35...

quihan
Level: Power Up

Re: Authorization Bearer in Header - Custom Connector

Hi @Dinesh, just wondering how are you updating your flow with a new connection? I tried using the Update Flow action to update the "connection reference" with the ID and Name created by the Create Connection Action. It works for the first run. But when I refresh my flow, the custom connectors result in a "connector not found" error.

 

Cheers,

Qui

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020.

thirdimage

Flow Community User Group Member Badge

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

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Flow Community Video Gallery!

Users Online
Currently online: 287 members 5,262 guests
Please welcome our newest community members: