Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
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
Solution Specialist
Solution Specialist

@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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.