Forum Discussion

YasirKazi77's avatar
YasirKazi77
Frequent Visitor
3 years ago
Solved

Use api token from text file in connection query

Hi,

I am getting data from an API that requires an authorization token to be passed in the connection string. Since the token needs to be renewed every 7 days, I want to read the token from a text file and reference that in the connection string (making it easier to replace the token)

I am able to read the token from the text file.

I read the token and store it in a variable "MyToken"

 

When I use the variable in a connection string  :

I get this error :

 

Any idea what I can do to fix the issue?

  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi YasirKazi77 ,

     

    You can right click your token column and Add as New Query. Then create a parameter suggested value as Query and use the Token Query. Then use the Parameter in your api query.

    For more details you can refer to below video, it will show you how to generate the token in Power BI and then add the token into your api query for authentication dynamiclly.

    Video:https://www.youtube.com/watch?v=N8qYRSqRz84

     

    Best Regards,
    Rico Zhou

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

3 Replies