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

322 views Asked by At

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?

1

There are 1 answers

0
Andrew St P On

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.