Forum Discussion
dcoronno
5 years agoRegular Visitor
POST Authentication to a REST API
Hi, I am having issues doing a POST method in M to grab an authentication token. Specifically I am trying to grab data out of the REST API to Power Query for Excel.. They have given a piece ...
Anonymous
5 years agoNot applicable
Hi dcoronno ,
You could try this
Get Access token in Power BI Desktop:
() =>
let
body = "client_id=" & #"App ID"
& "&scope=https://analysis.windows.net/powerbi/api/.default&client_secret=" & #"App Secret"
& "&grant_type=client_credentials",
Data= Json.Document(Web.Contents("https://login.microsoftonline.com/"& TenantID & "/oauth2/v2.0/token/",
[Headers=[#"Content-Type"="application/x-www-form-urlencoded"], Content=Text.ToBinary(body)])),
access_token = Data[access_token]
in
access_token
This is the official document you can refer to.
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.