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

前端 未结 7 1756
一生所求
一生所求 2020-12-04 11:32

I\'m adding Google Oauth2 to a Rails app, but have been unable to get past the early stages.

I\'ve set up an app, and defined client ID and secret.But I\'m getting <

相关标签:
7条回答
  • 2020-12-04 11:42

    Error redirect_uri_mismatch - This error can occur when you entered an incorrect bundle ID in your Google Developers Console project that does not match your app's bundle ID. Check that your client ID and bundle ID match the values that are displayed in the Developers Console.

    0 讨论(0)
  • 2020-12-04 11:49

    For me it was the function that built up the google url. I put line breaks in the string, once I removed the line breaks the url worked again.

    0 讨论(0)
  • 2020-12-04 11:52

    Using xip.io you can provide a public url to redirect to like http://your_pow_app.192.168.0.1.xip.io/user/auth/google_oauth2/callback

    Tested and working.

    0 讨论(0)
  • 2020-12-04 11:57

    I used my public hostname. It helps if you have a static IP address. I used http://www.displaymyhostname.com/ to get my hostname. I plugged it straight into the Authorized JavaScript origins field when I created a new Web Application Client ID.

    P.S. My hostname looked something like this: 111.111.111.111.static.exetel.com.au

    This is my answer to a related question https://stackoverflow.com/a/23517146/1320083

    0 讨论(0)
  • 2020-12-04 12:01

    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/
    0 讨论(0)
  • 2020-12-04 12:01

    I faced this issue but found it was really not an issue. As explained in my blog you can use the public redirect URI even when you are working on your localhost development machine. Google will just return the authorization code to the public URI where you can cut and paste it to your local machine.

    0 讨论(0)
提交回复
热议问题