W
Waspβ€’2mo ago
maksym36ua

Issue with Google Redirect URL while migrating 0.12.4 -> 0.13.0

Hey folks! Decided to migrate my app according to this guide: https://wasp-lang.dev/docs/migration-guides/migrate-from-0-12-to-0-13#migrate-your-oauth-setup. Getting redirect_uri_mismatch, upon further inspection there's a flowName=GeneralOAuthFlow being added at the end of the callback URL which was not the case before. I'm using googleSignInUrl from the auth package Code:
import { logout, useAuth, googleSignInUrl } from "wasp/client/auth";
...
<Button variant="teal" size={{ base: "md", md: "lg" }} onClick={e => { window.location.href = googleSignInUrl; }}>
import { logout, useAuth, googleSignInUrl } from "wasp/client/auth";
...
<Button variant="teal" size={{ base: "md", md: "lg" }} onClick={e => { window.location.href = googleSignInUrl; }}>
No description
7 Replies
kapa.ai
kapa.aiβ€’2mo ago
Hi @maksym36ua. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Based on the information provided in the knowledge sources, I can help you with your issue regarding the Google Redirect URL while migrating from Wasp 0.12.4 to 0.13.0. The migration guide you've followed is correct, but there's an important change in the redirect URL format that you need to update. According to the Migration from 0.12.X to 0.13.X guide, the redirect URL for OAuth providers has changed. Previously, the format was:
{clientUrl}/auth/login/{provider}
{clientUrl}/auth/login/{provider}
Now, in version 0.13.0, it should be:
{serverUrl}/auth/{provider}/callback
{serverUrl}/auth/{provider}/callback
This change is likely the reason you're experiencing the redirect_uri_mismatch error. The flowName=GeneralOAuthFlow parameter being added at the end is part of the new OAuth flow implemented in Wasp 0.13.0. To fix this issue, you need to update the redirect URL in your Google OAuth app settings. Here are the steps you should follow: 1. Go to your Google Cloud Console. 2. Navigate to the OAuth consent screen for your project. 3. Under "Authorized redirect URIs", update the URL to the new format: <http://localhost:3001/auth/google/callback> (for local development)
If you have a deployed version, also add: <https://your-server-url.com/auth/google/callback> 4. Save the changes. Additionally, make sure you've defined the WASP_SERVER_URL environment variable as mentioned in the migration guide. For local development, it defaults to <http://localhost:3001.> Your current code using googleSignInUrl should still work correctly after updating the redirect URL in the Google Console, as Wasp handles the generation of the correct URL internally. If you're still experiencing issues after making these changes, you might want to double-check your main.wasp file to ensure the Google auth method is correctly configured, as shown in the Google Auth API Reference. Let me know if you need any further clarification or if you encounter any other issues during the migration process. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @maksym36ua, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
maksym36ua
maksym36uaOPβ€’2mo ago
Redirect URL in Google Console looks correct
No description
maksym36ua
maksym36uaOPβ€’2mo ago
Can those external providers that are being used take time to propagate or something?
miho
mihoβ€’2mo ago
Hey Max πŸ˜„ That shouldn't be the case πŸ€·β€β™‚οΈ This is what I have in my Google setup. When you get the error "redirect_uri_mismatch" could you check the URL and see the redirect_uri param? Do curl -v http://localhost:3001/auth/google/login and see the Location header. In that header you'll find an URL with the redirect_uri param. What is it?
No description
maksym36ua
maksym36uaOPβ€’2mo ago
Hey Miho, I've cleaned up everything (both browser and my local files), the issue is gone now! No idea where the flowName=GeneralOAuthFlow originated from since I'm not in charge of the redirect_uri that gets sent to Google (since I'm using googleSignInUrl) and the redirect uri in Google Console was identical to what Wasp was sending except for that "flowName" part. I've seen people suggesting You may also need to remove flowName=GeneralOauthFlow as this is not going to be a valid redirect uri. on the web: https://stackoverflow.com/a/78777693 But in that case it was http / https mismatch, so not my case. Something cached on my side maybe, lol
Stack Overflow
Google OAuth return http redirect uri when in setting it's https
I have set up Google OAuth for my website. With Publishing status, I set Testing and in credentials, the redirect URI is http://vya.daotao.ai/auth/complete/google-oauth2/, Sign in with Google action
maksym36ua
maksym36uaOPβ€’2mo ago
Anyway, I'll mark the question as resolved, thanks πŸ™‚
miho
mihoβ€’2mo ago
Thanks for the feedback, I'm glad it got resolved πŸ™‚

Did you find this page helpful?