Link Search Menu Expand Document

OAuth: Troubleshooting - What to do when things go wrong?

If you are having issues with logging into OAuth, here’s a checklist of things to look at:

  1. Unless you are on localhost:8080, be sure you are using the https link and not the http link. OAuth only works with http on localhost, not on other platforms such as dokku.
  2. If you are using https and you are working with a dokku server (e.g. https://myapp.dokku-17.cs.ucsb.edu), check the Google Developer to make sure your callback urls have the correct address.
    • The callback url should start with https
    • It should then have your app name, followed by the dokku hostname. Be sure you got the correct dokku number, and not dokku-xx or something like that.
    • It should end in /login/oauth2/code/google for Google OAuth (which is the common cases for jpa and team type assignments, and most of the proj series assignments.
    • For proj-organic only, where Github OAuth is used, it should end in /login/oauth2/code/github instead.
  3. Check that your have the GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET set correctly
    • For localhost, check settings in .env
    • For dokku, check settings using dokku config show appname

There is more detail below on a specific example of troubleshooting.

Troubleshooting Example

If you see this:

Redirect URI Mismatch

Try clicking the little arrow to open up the additional message:

Request Details

Now, you’ll see the Redirect URI that the app is expecting.

If you go back to the Google Developer Console you can see what you really entered.

For example, when I was getting this error message, it’s because I put in this for my Redirect URI:

image

Rookie mistake! I literally had my-heroku-app instead of demo-spring-react-example.

Change it to the correct URI, click save. Then go back to the URL for the home page of your app and refresh the page (you don’t need to restart the application backend; just refresh your browser page.) Click login again, and you should get something like this:

Choose an Account

Success!