Hey gang, has anyone been able to connect to Wix via OAuth2? I’m struggling to build the resource using the OAuth2 flow.
Wix API Auth docs for context:
Thanks!
Hey gang, has anyone been able to connect to Wix via OAuth2? I’m struggling to build the resource using the OAuth2 flow.
Wix API Auth docs for context:
Thanks!
Hey @Decimal-Guy!
Are you running into any particular issues getting things set up? It can be really helpful to see specific error messages and what your configuration is so far (i.e. the resource setup page as well as your Wix OAuth2 setup).
Sensitive information redacted of course!
Hey @Kabirdas,
Here are some photo's of my resources setup (there is no sensitive data exposed).
The "Authentication" flow for Wix's API seemed pretty confusing but I know its possible to connect to it via HTTP client as I can connect to it via Make (No-code automation platform).
Thanks for that! Did some playing around with it and it looks like this one's a bit tricky. Usually for OAuth2 flows endpoints expect you to send a client id which Retool passes in the client_id
URL parameter. Wix is expecting it to come in the appId
URL parameter though which does not send with the default OAuth2 flow so we'll need to build it out ourselves using custom auth!
Following along with the doc you posted you'll first need to make a request to https://www.wix.com/installer/install
that includes a redirect URL to Retool as well as that appId
I mentioned. This will be the actual SSO part of the auth flow so we can use a "Redirect to SSO" step for it. Doing so provides us with the redirect URL we need (described as the "Callback url"). Both the redirectUrl
and appId
URL parameters need to be manually added to the "URL to redirect you to" field. So you'll end up with something like:
https://www.wix.com/installer/install?redirectUrl=https://<YOUR_DOMAIN>/oauth/user/redirectCallback&appId=<YOUR_APP_ID>
Note here that the redirect's URL parameters are exported as variables we can access.
For the next step, Wix requires a client_secret
which will correlate with your app's secret key, a client_id
this time which is still just your app id, as well as a
code
that's returned in the previous step's URL parameters. The first two can be found in your Wix app while the last we'll need to grab with a "Define a variable" step:
Then we can make the necessary POST request to https://www.wixapis.com/oauth/access
with an "API request" step:
This step returns the necessary auth token! We'll just need to define it as a new variable:
That can then be sent along with each request:
Finally, Wix's access tokens expire in 5 minutes it's important to refresh it using their associated endpoint. This requires first adding one more "Define a variable" step to the initial auth flow to save the refresh token:
Which can then be used in the following refresh flow:
Once you've authenticated the resource you should be able to hit their endpoints (like this empty blog):
Let me know if that helps!
Wow, that’s more complex for sure! Glad I was on the right path, I’ll work on this today and get back with you. Thanks so much!!