I am trying to generate the access token using the power query(authorization code) but getting the 400 bad request. any help is appreciated.
let
apiUrl = "https://login.mypurecloud.com/oauth/token",
body = "{""client_id: ""XXXXX"",
""client_secret"": ""XXXXXXX"",
""resource"":""https://analysis.windows.net/powerbi/api"",
""grant_type"": ""authorization_code""}",
Source = Json.Document(Web.Contents(apiUrl, [Headers = [Accept="application/json"], Content = Text.ToBinary(body)]))
in
Source
DataSource.Error: Web.Contents failed to get contents from (400): Bad Request
Details:
Please refer to the Authorization Code Documentation to learn how to fully set up the Authorization Code Grant.
I'm not familiar with Power BI, but after obtaining an authorization code, your code will look more like the following snippet:
let apiUrl = "https://login.mypurecloud.com/oauth/token",
body = {
"grant_type": "authorization_code",
"code": "<my-authorization-code>",
"redirect_uri": "<http://example.com/oauth/callback>"
},
Source = Json.Document(Web.Contents(apiUrl, [Headers = [Content-Type="application/x-www-form-urlencoded", Authorization="Basic BASE64(<client_id>:<client_secret>)"], Content = Text.ToBinary(body)]))
...
You'll have to refer to the Power BI documentation to learn how to BASE64 encode the <client_id>:<client_secret> pair.
system
Closed
3
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.