cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
ekstrem
New Member

How do I solve user API credentials in a report?

I´m doing a Power Bi report that use data from a API. I have done a table with the credentials to the API, username, password and subscriptionkey. The first question to all tables with data is to get the token from the API so I can ask the question correct. Looks like this in my table and the advanced editor:

"

Url = Text.Format("https://api.hey.com/fun/authentication/login?username=#{0}&password=#{1}",{#"UserIdFile", Uri.EscapeDataString(#"PasswordFile")}),
TokenSource = Json.Document(Web.Contents(Url, [Headers=[#"Ocp-Apim-Subscription-Key"=SubscriptionKey]])),
userCode = TokenSource[userCode],
Ask = Text.Format("https://api.hey.com/fun/v1/machines/#{0}/history/utilization?start=#{1}&end=#{2}&expand=1", {#"MachineId", #"startDate", #"endDate"}),
Source = Json.Document(Web.Contents(Ask, [Headers=[#"X-Auth-Token"=userCode, #"Ocp-Apim-Subscription-Key"=SubscriptionKey]])),

"

My table with the credentials looks like this:

creds.JPG

One row with my username, password and sub key.

When I refresh the reports everything works fine and I get new data.

 

But now the tricky part starts 🙂

My user of this reports when I publish them need to be able to update the credentials with their own ones. 

 

How do I solve that?

 

I have looked into using PowerApps with edit forms and other ways. I´m not a super user of PowerBi and PowerApps so maybe I have done something wrong....

1 REPLY 1
JirkaZ Resolver III
Resolver III

Re: How do I solve user API credentials in a report?

@ekstrem This can only be done using Power Query extension (and thus creating a custom connector for the API). 
https://docs.microsoft.com/en-us/power-query/handlingauthentication

 

Helpful resources

Announcements
New Ranks Launched March 24th!

New Ranks Launched March 24th!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power BI Community!

‘Better Together’ Contest Finalists Announced!

‘Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Arun 'Triple A' Event Video, Q&A, and Slides

Arun 'Triple A' Event Video, Q&A, and Slides

Missed the Arun 'Triple A' event or want to revisit it? We've got you covered! Check out the video, Q&A, and slides now.

Join THE global Microsoft Power Platform event series.

Join THE global Power Platform event series.

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities.

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors