Forum Discussion
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?
- Anonymous3 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 ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
3 Replies
- amitchandakSuper User
YasirKazi77 , refer if this can help
https://www.advaiya.com/generate-dynamic-token-and-get-data-from-custom-api-in-power-bi/
- YasirKazi77Frequent Visitor
Thanks Amit. I see that the solution you mentioned involves hard coding the username and password into the script , something that I want to avoid.
- AnonymousNot applicable
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 ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.