Hey folks, I’m trying to get some authentication related issues sorted. My auth works like this:
1. I get the user access and refresh tokens from my backend (Fastgen) in a redirect URL that goes to my toddle “PostLogin” page.
2. This PostLogin page runs a workflow on load that checks the url for an access token, and if it finds one, it stores the access token as a cookie.
So far, so good—I can see the access_token in my cookies. Here's where the trouble begins:
1. After logging in on the preview pages and getting the access token saved in my cookies, I still can’t make authenticated requests in the editor. I thought I should be able to do that because I have the latest toddle plugin installed (2.1). When I add the authorization in the header manually, the API requests work.
2. Relatedly, the Get Cookie formula still returns Null in the editor after logging in on the preview page. Even in the preview pages themselves I can’t seem to display the access token using the Get Cookie formula.
3. Without authorization in the editor, my APIs can’t fetch the data I need. Without this data, it makes it difficult to build formulas. Sometimes I know the path to get the info from the JSON, but I can’t click the path in the formula builder because the data is not populated. Is there a way to manually input a path (e.g., Fetch_user.data.Email) in these cases where I don’t have the data loaded in the editor?
4. Despite those issues, I’m still successfully storing the access_token as a cookie in my workflow. That success triggers another workflow where I fetch the username and email from my backend and stores this data in local storage. While the fetch request is working, for some reason the user information is not being saved in local storage.
5. Oddly, if I login a second time, the user information does get saved in local storage. So I have to login twice for my on success action to save the user data to local storage.
Okay, that’s what I’ve been pulling my hair about! 😉