Forum Discussion
X-API-KEY outside Headers
Hello,
I'm connecting to an API that has Oauth2, and so far I have been able to connect using a Refresh Token as a parameter. The problem with this is not safe, because the parameter is exposed in PowerBI service.
I'm trying to use X-API-KEY outside the headers but seems PowerBI doesn't recognize the "X-API-KEY"
For example, if I put X-API-KEY into a string
content = "{
""grant_type"":""refresh_token"",
""refresh_token"": "&X-API-KEY&",
}",
Headers_accesstoken = [Headers=[#"Content-Type"="application/json" ],Content=Text.ToBinary(content)],
AccessToken = Json.Document(Web.Contents("https://my_url.com/oauth/token",Headers_accesstoken))[access_token],
In this case, the API KEY has to be generated and cannot be provided once because it will expire quite rapidly.
I can also work with User and Password outside the headers as well.
The access Token is used like this:
options = [Headers =[Authorization="Bearer " & AccessToken]],
API_CALL = Json.Document(Web.Contents("myurl.com/action", options))
2 Replies
- amitchandak
Super User
acanepa , Not very clear to me
refer, if these can help
https://www.youtube.com/watch?v=GPHHdDRSlis
- acanepa
Resolver I
Hello amitchandak ,
Thanks for your response but those links refer to PowerBI embedded, a different topic.
I'm trying to store API credentials using the X-API-KEY functionality in PowerBI Desktop and Service., outside the headers of a Web.Contents function - or any similar process that would allow storing credentials safely.
Because I don't have a static API key I need to generate it first as an access token and later using in an API CALL.
Hope that makes sense.
Regards,