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
4 Replies
kapa.ai
kapa.ai4d 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
maksym36uaOP4d ago
Redirect URL in Google Console looks correct
No description
maksym36ua
maksym36uaOP4d ago
Can those external providers that are being used take time to propagate or something?
miho
miho3d 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

Did you find this page helpful?