Forum Discussion
mschoenhub
3 years agoFrequent Visitor
Cannot apply operator & to types Text and Function
Dear all, I am trying to use a bearer token which I get from a function in a query. Function: () =>
let
// Get the API Token
api_url = "https://api.xxxxxxx.com",
token_path = "/o...
- 3 years ago
Ha mschoenhub ,
that was a tricky one 🙂
In the function for the token, you are not returning the last step.
Please change it to this:() => let // Get the API Token api_url = "https://api.xxxxxxx.com", token_path = "/oauth2/access_token", ClientID = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", Secret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", EncodedCredentials = "Basic " & Binary.ToText(Text.ToBinary(ClientID & ":" & Secret), BinaryEncoding.Base64), Token_Response = Json.Document(Web.Contents(api_url, [ RelativePath = token_path, Headers = [#"Content-Type"="application/x-www-form-urlencoded",#"Authorization"=EncodedCredentials], Content=Text.ToBinary("grant_type=client_credentials") ] ) ), // Get the token from the API response token = Token_Response[access_token] in token
ImkeF
3 years agoCommunity Champion
Ha mschoenhub ,
that was a tricky one 🙂
In the function for the token, you are not returning the last step.
Please change it to this:
() =>
let
// Get the API Token
api_url = "https://api.xxxxxxx.com",
token_path = "/oauth2/access_token",
ClientID = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
Secret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
EncodedCredentials = "Basic " & Binary.ToText(Text.ToBinary(ClientID & ":" & Secret), BinaryEncoding.Base64),
Token_Response = Json.Document(Web.Contents(api_url,
[
RelativePath = token_path,
Headers = [#"Content-Type"="application/x-www-form-urlencoded",#"Authorization"=EncodedCredentials],
Content=Text.ToBinary("grant_type=client_credentials")
]
)
),
// Get the token from the API response
token = Token_Response[access_token]
in
tokenmschoenhub
3 years agoFrequent Visitor
We are making progress. Thank you very much! In Postman I have access to the resource. Now it could be that I need to specify a scope (scope = "library:read"). How would I do that?
But if I insert the token directly then it actually works. So maybe the scope is not the issue.