Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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.
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
72 | |
67 | |
51 | |
38 | |
26 |
User | Count |
---|---|
89 | |
52 | |
45 | |
39 | |
38 |