Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): Convert authentication config source functions to actual functions #660

Merged
merged 1 commit into from
Jun 22, 2023

Conversation

FokkeZB
Copy link
Contributor

@FokkeZB FokkeZB commented Jun 9, 2023

IP-127 Zapier Convert: Convert auth config source to functions

Inline functions under auth config objects are not converted to functions by zapier convert, while the test function is:

const testAuth = async (z, bundle) => {
  z.request({
    url: "https://api.wistia.com/v1/account.json",
    method: "GET",
    headers: {
      Authorization: "Bearer {{bundle.authData.access_token}}",
    },
    body: {},
  }).then((response) => response.data);
};

module.exports = {
  type: 'oauth2',
  test: testAuth,
  fields: [],
  oauth2Config: {
    getAccessToken: {
      source:
        "const options = {\n  url: 'https://api.wistia.com/oauth/token',\n  method: 'POST',\n  headers: {\n    'content-type': 'application/x-www-form-urlencoded',\n    accept: 'application/json',\n  },\n  body: {\n    grant_type: 'refresh_token',\n    refresh_token: '{{bundle.authData.refresh_token}}',\n  }\n}\n\nreturn z.request(options)\n  .then((response) => {\n    const results = response.data;\n\n    // You can do any parsing you need for results here before returning them\n\n    return results;\n  });",
    },
  },
};

This PR fixes that my traversing to look for any source: and adds missing test coverage.

@FokkeZB
Copy link
Contributor Author

FokkeZB commented Jun 21, 2023

@eliangcs this change is likely less controversial and will help with Py2CLI.

eliangcs
eliangcs previously approved these changes Jun 22, 2023
Copy link
Member

@eliangcs eliangcs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested with a few apps and it works great! I only have a comment on the traverse package version used in package.json. Otherwise, it looks good to me!

packages/cli/package.json Outdated Show resolved Hide resolved
Copy link
Member

@eliangcs eliangcs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Merging.

@eliangcs eliangcs merged commit f99bf1e into zapier:main Jun 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants