Search code examples
oauthgoogle-oauthgoogle-developers-consolenext-auth

Getting login and redirect issues from Google


Trying to set up an Authentication for my app, and all seemed to be working correctly, but when I tried testing it out I got this error message

Authorization Error Error 400: redirect_uri_mismatch The redirect URI in the request, http://localhost:3000/api/auth/callback/google, does not match the ones authorized for the OAuth client. To update the authorized redirect URIs, visit: https://console.developers.google.com/apis/credentials/oauthclient/${your_client_id}?project=${your_project_number}

Can you point me in the right direction to fixing this?


Solution

  • Error 400: redirect_uri_mismatch

    Is a configuration issue. The redirect uri is used to return the authorization code to your application after the user has consented to your applications access to your data. You have created a web client credentials up on Google developer console.

    What you need to do is go back there and add a Redirect uri of

     http://localhost:3000/api/auth/callback/google
    

    It must match exactly don't add any spaces at the end or anything.

    If you have any issues i have a video which will show you exactly how to add it Google OAuth2: How the fix redirect_uri_mismatch error. Part 2 server sided web applications.