Skip to content

Step Function - Call Third party API - Bearer Token

0

I am attempting to invoke an external API via Step functions that requires authorization in the form of:

-H "Authorization: Bearer <TOKEN_HERE>"

I have attempted a variety of combinations in the configured connection, for example:

  • Bearer/Token using "API Key" as the Auth Type
  • Using Invocation Http Parameters (Secret Header, Bearer, Token)
  • I also attempted Header, same as above

All have failed. Is this type of authorization possible, and if so, what am I missing in the setup of the Connection that the Step Function will use? Are there examples of this type of authorization documented?

Obviously I can get around this by invoking a lambda function within the Step Function, but I was hoping to keep this contained within the definition of the state machine.

1 Answer
0
Accepted Answer

Hello.

Before configuring StepFunctions, try configuring EventBridge with the settings in the document below.
When configuring, try including the token in the header like below.
https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-api-destinations.html
https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-target-connection.html
a

Once created, you should be able to select EventBridge for StepFunctions authentication.
I think you can authenticate by selecting this.
a

This is explained in the AWS blog below.
https://aws.amazon.com/jp/blogs/aws/external-endpoints-and-testing-of-task-states-now-available-in-aws-step-functions/

EXPERT

answered 2 years ago

EXPERT

reviewed 2 years ago

  • Thank you for the response. For my future self, or anyone that comes across this, above shows that for the Key Name, we use Authorization. What is not discussed above, and perhaps not obvious, is that for the value, you would enter Bearer <TOKEN>.

    Moreover, to get this to work, I needed to add an additional Header under Invocation Http Parameters shown in the screenshot of the answer. I did not itemize this above, but may be necessary depending on the external service.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.