Webflow-Examples / hybrid-app-example

Webflow App example using both Webflow's Designer and Data APIs
8 stars 14 forks source link

Wrong redirect after log in #15

Open MaksymUstianov opened 10 months ago

MaksymUstianov commented 10 months ago

After logining in app anyway redirects me to login page. I`ve already added .env.local file which contains CLIENT_ID and CLIENT_SECRET. What am I doing wrong?

lunchpaillola commented 10 months ago

I believe you need to make sure that your app has the /webflow_redirect in the URI and the .env.local has to be in the same folder with data-client (and another one in the same folder as designer-extension)

Screenshot 2023-10-23 at 12 13 45 AM
key88sf commented 9 months ago

Still not working. Going to my /login page, I see the "Login with Your Webflow Account" page. When i click Login, I just keep getting sent back to the /login page.

The terminal shows: [1] TEST ERROR each time.

lunchpaillola commented 9 months ago

Still not working. Going to my /login page, I see the "Login with Your Webflow Account" page. When i click Login, I just keep getting sent back to the /login page.

The terminal shows: [1] TEST ERROR each time.

Oh interesting, at least for me the TEST ERROR logs all the time even when it was successful. What scopes do you have authorized and what does your .env.local look like? I also noticed on the forum someone was able to authorize by going to http://localhost/3001 instead of the NGROK URL since NGROK was giving them an infinite loop

key88sf commented 9 months ago

In the Webflow UI where I created the app, I selected Asset [Read + Write], Authorized User [Read], CMS [Read].

Do I need to specify these same scopes somewhere in the code as well?

lunchpaillola commented 9 months ago

In the Webflow UI where I created the app, I selected Asset [Read + Write], Authorized User [Read], CMS [Read].

Do I need to specify these same scopes somewhere in the code as well?

I think you need all the scopes to run this particular project. That's what they put in the webflow_helper

So that could be part of the issue!

const ALL_SCOPES = [
  'assets:read',
  'assets:write',
  'authorized_user:read',
  'cms:read',
  'cms:write',
  'custom_code:read',
  'custom_code:write',
  'forms:read',
  'forms:write',
  'pages:read',
  'pages:write',
  'sites:read',
  'sites:write',
];
key88sf commented 9 months ago

@lunchpaillola Ok well that worked. It's odd that these scopes have to be set in two different places, instead of a single source of truth.

Why does the designer app need to have the access token copy/pasted from the backend data app? Is this true of all hybrid apps in Webflow -- the user will need to copy/paste that access token into the designer app in order for any communication between the two to work?

lunchpaillola commented 9 months ago

@key88sf I think that was for simplicity for this demo, Webflow also has an example where the token stores externally (https://github.com/Webflow-Examples/Apps-v2-Hybrid-Auth-Demo) so it's definitely not required but I believe you'll need to store the token somewhere if you want to avoid the manual copy/pasting

key88sf commented 9 months ago

@lunchpaillola Ok thanks. Is it possible to store/persist additional data in a webflow app? For example, if we wanted to allow the user to enter their OpenAI api key here, and then store it to use each time they use this app, is that possible?

lunchpaillola commented 9 months ago

@key88sf I think you'd need to connect to an external database for that too. i've been thinking of using unkey.dev (https://unkey.dev/) for a lightweight option to store some information without using a whole database but my sense is that a db, or API key management system is required

key88sf commented 9 months ago

Cool, will check that out. 👍