twinslash / redmine_omniauth_google

This plugin is used to authenticate in redmine through Google.
http://www.redmine.org/plugins/redmine_omniauth_google
95 stars 103 forks source link

redirect_uri_mismatch #15

Open leventyalcin opened 10 years ago

leventyalcin commented 10 years ago

Hi,

I tried everything i can do but no luck. Only I can see error above.

Error: redirect_uri_mismatch

The redirect URI in the request: http://redmine.domain.com/oauth2callback did not match a registered redirect URI.

Learn more

Request Details
from_login=1
response_type=code
scope=https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile
redirect_uri=http://redmine.domain.com/oauth2callback
as=-9c076da2e673a8
client_id=910957160597-mu1o3prbc01v9sf2tg4nc8livv450jdk.apps.googleusercontent.com
hl=en-US

I'm sure it is not HTTP:// at Google Developer Console http://prntscr.com/4ptsql

Processing by RedmineOauthController#oauth_google as HTML
  Parameters: {"back_url"=>"https://redmine.domain.com/"}
  Current user: anonymous
Redirected to https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=910957160597-mu1o3prbc01v9sf2tg4nc8livv450jdk.apps.googleusercontent.com&redirect_uri=http%3A%2F%2Fredmine.domain.com%2Foauth2callback&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile
Completed 302 Found in 9.1ms (ActiveRecord: 0.3ms)

ignore domain.com i changed it

leventyalcin commented 10 years ago

When I force to HTTPS I started to get error below;

Error: invalid_client

no application name

Request Details
scope=https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile
response_type=code
redirect_uri=https://redmine.domain.com/oauth2callback
client_id=910957160597-mu1o3prbc01v9sf2tg4nc8livv450jdk.apps.googleuserconte

Changes I've made

# diff redmine_omniauth_google/app/controllers/redmine_oauth_controller.rb /tmp/redmine_oauth_controller.rb
10c10
<       redirect_to oauth_client.auth_code.authorize_url(:redirect_uri => 'https://redmine.domain.com/oauth2callback', :scope => scopes)
---
>       redirect_to oauth_client.auth_code.authorize_url(:redirect_uri => oauth_google_callback_url, :scope => scopes)
21c21
<       token = oauth_client.auth_code.get_token(params[:code], :redirect_uri => 'https://redmine.domain.com/oauth2callback')
---
>       token = oauth_client.auth_code.get_token(params[:code], :redirect_uri => oauth_google_callback_url)
leventyalcin commented 10 years ago

Stopped thin and started webrick with SSL support and URLs changed to HTTPs but still no luck

Error: invalid_client

no application name
Request Details

    scope=https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile
    response_type=code
    redirect_uri=https://redmine.domain.com/oauth2callback
    client_id=910957160597-8u7iqo3pa10p3i6i54ls74daut8jg3f0.apps.googleusercontent.com

That’s all we know.

And stil I'm sure Google Apps configuration is OK. http://prntscr.com/4pwicg

leventyalcin commented 10 years ago

So, Found what is wrong at here http://stackoverflow.com/a/18951654/953706 and it works now.

I just still no idea why it sets protocol from server insted of requests. It works like SSL Requests -> Nginx -> SSL Requests -> Webrick (thin etc). dunno. Maybe I'm missing something.