Invalid client #20

afrankel opened this Issue Mar 6, 2012 · 8 comments


None yet
6 participants

afrankel commented Mar 6, 2012

Sorry, but I seem to be missing something obvious here. I'm a newbie.

I have the following config (using devise, omniauth):

config.omniauth :google_oauth2, "[my key]", "[secret]", {access_type: 'online', approval_prompt: ''}

[my key] above also happens to equal [my domain]

I get 400 Bad Request:

Error: invalid_client
Request Details
redirect_uri=https://[my domain]/users/auth/google_oauth2/callback
client_id=[my domain]

I think it has to do with one of a few possibilities:

  1. I have ssl on my app and I'm wondering if I need to pass additional parms.

  2. I am not using the right key/secret. I have found 3 places on google (apps) to set up oauth keys:
    a) - where I have it set up and I'm using this key/secret
    b) - where I have it set up but I'm NOT using this key/secret
    c)[mydomain]/SetupOAuth - I am NOT using this one.

What am I missing?

Thanks in advance.


zquestz commented Mar 6, 2012

I think your just using the wrong key/secret. You want to use the key/secret from


afrankel commented Mar 6, 2012

Yes! That was it.

For others who stumble upon this issue the other thing I had wrong was the redirect URL I registered with google. Ours is:
http://localhost:3000/users/auth/google_oauth2/callback - not the default that google had. You will get a redirect issue if you don't set it correctly.

Works great! Even the no-reauth parameter works as I want it.

Thank you much.

afrankel closed this Mar 6, 2012


zquestz commented Mar 7, 2012

Glad you figured it out. =) -> for OAuth -> OAuth2 (This is the right one for YouTube Oauth 2)[mydomain]/SetupOAuth -> Service to Your Google App admin, i.e. Gmail, Calendar, etc.

You can curl -H 'Authorization: OAuth ya29.reset of the Key'

I have wasted almost a week on this, still unable to make it work :( Heres what all I have setup.


config.omniauth :google_oauth2, 'CLIENT_ID', 'KEY', { access_type: "offline", approval_prompt: "" }


devise_for :users, :controllers => {:omniauth_callbacks => "users/omniauth_callbacks"}

Enabled Contact and Google+ API on Google Developer Console.
Redirect URIs : http://localhost:3000/
Javascript Origins : http://localhost:3000/
I have tried http and https combinations, re-generated keys and renamed project tons of time and waited for more than 10 mins. after changes, still I am getting "Err 400 : redirect_uri_mismatch" error saying that :

The redirect URI in the request: https://localhost:3000/users/auth/google_oauth2/callback did not match a registered redirect URI

Can anyone help in making it work ?

It worked finally when I changed the Redirect URI to the full callback URL as follows:


instead of mentioning only


i have error, when i trying for login with google plus with this url


but i get error such

No route matches [GET] "/auth/google_oauth2"

can anyone help in making it work?

Can you post your routes.rb file so we can debug your problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment