Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and a 50 percent discount on exams.
Get startedEarn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Hi, I am currently connecting to the API through Power Query with M Language, in the code I am entering the username and password to obtain the API token and later I will make another query that will serve me for the report.
my example is the following:
let
vUrlGetToken = "https://my-api-with-security.com/spa/login",
parameters = "{ ""email"": ""user@user.com"", ""password"": ""1234567""}",
Parsed_JSON = Json.Document(parameters),
BuildQueryString = Uri.BuildQueryString(Parsed_JSON),
Source = Json.Document(Web.Contents(vUrlGetToken,[Headers = [#"Content-Type"="application/x-www-form-urlencoded"], Content = Text.ToBinary(BuildQueryString) ] )),
vToken = "Bearer "&Source[token],
vUrl ="https://my-api-with-security.com/spa/powerbi/get_list_report",
content = "{
""method"": ""post"",
}",
Origen = Json.Document(Web.Contents(vUrl, [
Headers=[#"Authorization" = vToken, #"Content-Type"="application/json"],
Content=Text.ToBinary(content)
])),
rows = Origen[rows],
in
rows
As you can see I am doing:
parameters = "{ ""email"": ""user@user.com"", ""password"": ""1234567""}",
But I need to find a way to not have to enter the username and password from the M language, there is some way that through Power BI when opening the report, it asks me for the username and password, this username and password is received by the M language in power query and do continue with workflow ?
Is there any such functionality? and thus not expose the username and password in the Power Query?
you already received your Bearer token. Use it in the subsequent API calls.
the question is more focused on not being visually the username and password.
Hi @jggj
You may try the query parameter in Power Query.
Parameters - Power Query | Microsoft Docs
Create a parameter query (Power Query) (microsoft.com)
Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.
Store your user name and password in a sharepoint file. Access that file via Power Query Sharepoint Folder connector, read its contents and put it in the query.
Beware the Formula Firewall.
By any chance, do you have an example that applies to what I have already worked on, to guide me. I don't really know where to start. Thanks a lot.
User | Count |
---|---|
96 | |
87 | |
78 | |
72 | |
69 |
User | Count |
---|---|
113 | |
105 | |
84 | |
65 | |
64 |