Why is Google Oauth returning `invalid redirect_urI` in my Rails app?

I was getting the redirect error for my python / tornado app running on ubuntu. Using localhost didn’t work as the accepted answer highlighted. Google wants a public domain.

My solution was to piggyback “example.com” which is public and create a sub domain in my /etc/hosts file. The sub domain would work on my local dev box and google would be happy with the example.com domain. I registering the redirects via the google console and the redirect worked successfully for me.

I added the following to my /etc/hosts:

192.168.33.100   devbox  devbox.example.com

In my case the IP was that of my machine. I could also have used 127.0.0.1 instead.

My Google API console (https://code.google.com/apis/console) set up for a new client ID was:

  • “Application Type: Web Application”.
  • Via “Your site or hostname (more options)”:
    • In “Authorized Redirect URIs” I entered http://devbox.example.com/
    • In “Authorized JavaScript Origins” I entered http://devbox.example.com/

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)