Adil B
Adil B

Reputation: 16778

How do I generate authentication tokens within Foundry Code Workbook to use as an argument to APIs?

In a Foundry Code Workbook, I'm trying to make a call to an API where one of the arguments is an authentication token.

What is the best way to generate authentication tokens during execution? Can they be reused in multiple calls?

Upvotes: 0

Views: 376

Answers (1)

Andrew St P
Andrew St P

Reputation: 584

You can use the command below to get a token during the execute stage:

token = spark.sparkContext.getLocalProperty('foundry.spark.session.bearerToken')

The token should be available for more than one call. If you need different/new tokens you can call the Multipass API to generate a new one.

Upvotes: 0

Related Questions