Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

redirect_uri_mismatch for any additional uris added to oauth clients

Hey I cannot for the life of me understand why I am unable to resolve this redirect uri mismatch error I keep getting.

I have a NextJS app where I am trying to allow users to click to sign-in and give access to the google calendar. I was able to get it to work successfully for one uri. However all my attempts to add a second uri have been blocked by this error. I've triple-checked to ensure no spaces, trailing slashes, or letter cases were the issue. I've double-checked to make sure the client id and secret were correctly stored in my env variables. However, nothing seems to work. 

My current workaround is using the working uri and modifying the code to handle multiple situations. But I would rather just separate the logic instead of sending multiple instances for different sets of users to the same redirect uri. I have attached a code snippet with the problematic code, snippet from the working code with the other uri, and a screenshot of my client setup. Just to note, when I directed the problematic code to the working uri it sent me to the next oauth screen successfully. 

Broken Code:

Screenshot 2024-06-21 at 9.21.36 AM.png

Working Code:

Screenshot 2024-06-21 at 9.20.29 AM.png

OAuth Client Setup

Screenshot 2024-06-21 at 9.21.54 AM.png

0 0 298
0 REPLIES 0