Open why-silvio opened 3 weeks ago
Hello, @why-silvio 👋. Are you by chance experiencing this on Safari specifically? I ask because Webkit-based browsers like Safari will require the secure
attribute to be true
. The auth tokens won't be written into your cookie store if you're doing the following on Safari:
cognitoUserPoolsTokenProvider.setKeyValueStorage(
new CookieStorage({
secure: false //process.env.NODE_ENV !== 'development'
})
);
HTTPS is recommended anyways as a best practice, but if this is happening on a non-Webkit-based browser then let us know. If this is not happening on Safari though, can you share what you see in the network tabs for the sign-in requests? Are there any exceptions or 4XX codes you can share via a screenshot or text of what the response is?
Hi @cwomack thank you for your quick reply. I think I found the issue that results in a redirect loop on my end.
I can see that the response from Google SSO gets first stored into the localstorage for some milliseconds and only after maybe 0.5 seconds it gets deleted from localstorage and saved into cookie storage. However, within that time my code already does a redirect as it couldn't find the tokens in the cookiestorage. Is this storage behavior wanted?
I didn't yet figure out how to solve this (so far I only see the cookies properly placed when I stop the redirect process but then the user needs to click a second time on login to actually get redirected to "/" which is not ideal) so I am still looking for a solution that works. Can it be an issue that I handle the redirect and cookie reading on the server side? Like said for the email/password flow it works as fine.
@why-silvio, appreciate the follow up here and additional context. We're going to work on reproducing this on our side and digging into this further, but will follow up soon.
Before opening, please confirm:
JavaScript Framework
Not applicable
Amplify APIs
Authentication
Amplify Version
v6
Amplify Categories
auth
Backend
Amplify Gen 2
Environment information
Describe the bug
I am using sveltekit in combination with amplify Gen2 and I store the authentication tokens in cookieStorage. This works well for email/password authentication but when I want to use the Google Sign In option it writes the tokens in localStorage. It seems it ignores the cookieStorage setup.
I have an authentication page localhost:5173/authentication/login with the button that triggers the Google Sign In. The redirect should happen to localhost:5173/
Expected behavior
Storing the token information in the cookieStorage.
Reproduction steps
Code Snippet
Log output
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response