Forum Discussion
Custom Connector OAuth2 Scheduled Refresh Issue
I managed to make it work, it was a problem in one of my functions (I will check if I remember which one)
And I can confirm that Custom Connectors do refresh through the Gateway (no need to be the personal one).
EDIT: Found it. I implemented a logic developed by Matt Mason in the TokenMethod function. After this change, it worked.
TokenMethod = (grantType, code) =>
let
query = [
grant_type = grantType,
client_id = client_id,
client_secret = client_secret,
redirect_uri = redirect_uri
],
// Code from Matt Mason. Check https://www.mattmasson.com/
queryWithCode = if (grantType = "refresh_token") then [ refresh_token = code ] else [code = code],
response = Web.Contents(token_uri, [
Content = Text.ToBinary(Uri.BuildQueryString(query & queryWithCode)),
Headers=[#"Content-type" = "application/x-www-form-urlencoded",#"Accept" = "application/json"], ManualStatusHandling = {400}]),
body = Json.Document(response),
result = if (Record.HasFields(body, {"error", "error_description"}))
then error Error.Record(body[error], body[error_description], body)
else body
in
result;
Refresh = (resourceUrl, refresh_token) => TokenMethod("refresh_token", refresh_token);
Anonymous ,
Could you please help me with the entire code that worked in your case?