Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

oAuth failing - NoMethodError in Users::OmniauthCallbacksController#google_oauth2 - request.env['omniauth.auth'] #193

Closed
DrIanGregory opened this issue Oct 27, 2021 · 1 comment

Comments

@DrIanGregory
Copy link

DrIanGregory commented Oct 27, 2021

oAuth fails to obtain credentials.

Installed gate-sso in Ubuntu location /opt/gate. Running on port 82 and reverse proxy to 80.
In .env:
GATE_SERVER_URL=http://gate.orthogonal.trading/

Setup Google API keys.

Click on Single Sign on. Then when clicking on the Google email account to login with. gate-sso crashes with the error:
"NoMethodError in Users::OmniauthCallbacksController#google_oauth2"
"undefined method `[]' for nil:NilClass"

In file: app/controllers/users/omniauth_callbacks_controller.rb:7:in `google_oauth2'.
The code lines causing the issue:

data = request.env['omniauth.auth']
domain = data['info']['email'].split('@').last

These are the parameters sent in the request:

Parameters:

{"state"=>"83d21c734d8daf7647a742553453067fc4c8d47b8fd1daf9",
"code"=>"4/0AX4XfWhZWa6BTZxezs0M8UT-CIn2JEwDamE45JOD7T1ggkYVCAJR4V0ezeg9MoO5Z2XIzg",
"scope"=>"email profile https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile openid",
"authuser"=>"1",
"hd"=>"orthogonal.trading",
"prompt"=>"consent"}

Response
Headers:
None

@DrIanGregory
Copy link
Author

Issue resolved by editing .env many times:
https://github.com/gate-sso/gate/blob/master/.env.example

And reading this many many times:
https://github.com/gate-sso/gate/blob/master/docs/oauth_setup.md

And running the following many many times:

sudo lsof -i -P -n | grep LISTEN
sudo kill -9
rake app:setup
rvmsudo rails server --port 82 --binding 0.0.0.0 --daemon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant