The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hi evereyone
I'm new to power bi and I'm trying an OAuth using the GET method. But it's not the conventional way, I think.
I can show you the issue with swagger. I get a connection, if i dont fill the 'Bearer token'. I have to give a Request Header as shown.
But how to build that in M-Code?
I have read many instructions on the net, maybe all of them, but I can't find a solution.
See my last attempt:
Can anyone please help me?
Regards
Solved! Go to Solution.
Hi @Anonymous ,
I think you can follow the below step to get access token and get data from API.
() =>
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
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
HI everyone
Sorry for delay, I had to take a little Corona break.
The solution works fine now, thanks to all.
regards
Mulder
HI everyone
Sorry for delay, I had to take a little Corona break.
The solution works fine now, thanks to all.
regards
Mulder
Hi @Anonymous ,
I think you can follow the below step to get access token and get data from API.
() =>
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
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@Anonymous , Not very sure on get part. but check if these can help
https://community.powerbi.com/t5/Power-Query/OAuth2-REST-API-as-data-source/td-p/414748
HI amitchandak
authToken = "bearer " & token, //Required by documentation.
[Headers=[Authorization=authToken]]
It seems like i cant use the Authorization Methode like this.
The same when i try to fill the OAuth Token in swagger, it doesent work.
But Thanks fpr reply
Regards