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:
- Unless you are on
localhost:8080
, be sure you are using thehttps
link and not thehttp
link. OAuth only works withhttp
onlocalhost
, not on other platforms such as dokku. - 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 forjpa
andteam
type assignments, and most of theproj
series assignments. - For
proj-organic
only, where Github OAuth is used, it should end in/login/oauth2/code/github
instead.
- The callback url should start with
- Check that your have the
GOOGLE_CLIENT_ID
andGOOGLE_CLIENT_SECRET
set correctly- For
localhost
, check settings in.env
- For dokku, check settings using dokku config show appname
- For
There is more detail below on a specific example of troubleshooting.
Troubleshooting Example
If you see this:
Try clicking the little arrow to open up the additional message:
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:
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:
Success!