OmniAuth Google returning "Example User" in the AuthHash ignoring my actual account info?
I seem to be having a problem since merging the latest updates with trying to connect my account with Google. Previously all worked. But now I'm getting the following error when trying to connect the account:
NoMethodError in Users::OmniauthCallbacksController#google_oauth2
It goes on to say:
undefined method `token' for nil:NilClass
Running a test to see what AuthHash is being returned, I get the following:
#<OmniAuth::AuthHash info=#<OmniAuth::AuthHash::InfoHash name="Example User"> provider="default" uid="1234">
Which is for a test user. However I have set up my google_oauth2 credentials correctly. I'm running it from localhost and this is all being accepted by google.
Can anyone point me in the right direction as to why jumpstart appears to be ignoring my access tokens etc or why I'm getting back Test Data and not what I'm expecting.
Thanks
#<OmniAuth::AuthHash info=#<OmniAuth::AuthHash::InfoHash name="Example User"> provider="default" uid="1234">
Which is for a test user. However I have set up my google_oauth2 credentials correctly. I'm running it from localhost and this is all being accepted by google.
Can anyone point me in the right direction as to why jumpstart appears to be ignoring my access tokens etc or why I'm getting back Test Data and not what I'm expecting.
Thanks
Hey Darren,
Do you have a stacktrace you can share?
The developer Omniauth provider is only added in the "test" environment as you can see here: https://gitlab.com/gorails/jumpstart-pro/blob/master/config%2Finitializers%2Fdevise.rb#L322-324
Do you have a stacktrace you can share?
The developer Omniauth provider is only added in the "test" environment as you can see here: https://gitlab.com/gorails/jumpstart-pro/blob/master/config%2Finitializers%2Fdevise.rb#L322-324
Hi
Chris Oliver
Firstly, congratulations on your engagement!
I did some quick research and yes, it seemed that the Example User is from the "test" environment ...
Here is the output from the call:
11:33:06 web.1 | Started POST "/users/auth/google_oauth2" for ::1 at 2019-09-12 11:33:06 +1000
Firstly, congratulations on your engagement!
I did some quick research and yes, it seemed that the Example User is from the "test" environment ...
Here is the output from the call:
11:33:06 web.1 | Started POST "/users/auth/google_oauth2" for ::1 at 2019-09-12 11:33:06 +1000
11:33:06 web.1 | Started GET "/users/auth/google_oauth2/callback" for ::1 at 2019-09-12 11:33:06 +1000
11:33:06 web.1 | Processing by Users::OmniauthCallbacksController#google_oauth2 as HTML
11:33:06 web.1 | User::ConnectedAccount Load (0.3ms) SELECT "user_connected_accounts".* FROM "user_connected_accounts" WHERE "user_connected_accounts"."provider" = $1 AND "user_connected_accounts"."uid" = $2 ORDER BY "user_connected_accounts"."id" ASC LIMIT $3 [["provider", "default"], ["uid", "1234"], ["LIMIT", 1]]
11:33:06 web.1 | ↳ app/models/user/connected_account.rb:46:in `for_auth'
11:33:06 web.1 | User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT $2 [["id", 1], ["LIMIT", 1]]
11:33:06 web.1 | ↳ lib/jumpstart/app/controllers/jumpstart/omniauth_callbacks_controller.rb:12:in `block (2 levels) in <class:OmniauthCallbacksController>'
11:33:06 web.1 | I have the auth as: #<OmniAuth::AuthHash info=#<OmniAuth::AuthHash::InfoHash name="Example User"> provider="default" uid="1234">
11:33:06 web.1 | Completed 500 Internal Server Error in 4ms (ActiveRecord: 0.6ms | Allocations: 2786)
11:33:06 web.1 |
11:33:06 web.1 |
11:33:06 web.1 |
11:33:06 web.1 | NoMethodError (undefined method `token' for nil:NilClass):
11:33:06 web.1 |
11:33:06 web.1 | lib/jumpstart/app/controllers/jumpstart/omniauth_callbacks_controller.rb:108:in `connected_account_params'
11:33:06 web.1 | lib/jumpstart/app/controllers/jumpstart/omniauth_callbacks_controller.rb:70:in `attach_account'
11:33:06 web.1 | lib/jumpstart/app/controllers/jumpstart/omniauth_callbacks_controller.rb:15:in `block (2 levels) in <class:OmniauthCallbacksController>'
I checked to see what happened when I did 'foreman start' to see if it starts in the test mode. This is what I get:
11:36:18 web.1 | Puma starting in single mode...
I checked to see what happened when I did 'foreman start' to see if it starts in the test mode. This is what I get:
11:36:18 web.1 | Puma starting in single mode...
11:36:18 web.1 | * Version 4.1.0 (ruby 2.6.4-p104), codename: Fourth and One
11:36:18 web.1 | * Min threads: 5, max threads: 5
11:36:18 web.1 | * Environment: development
11:36:18 web.1 | * Listening on tcp://localhost:5000
11:36:18 web.1 | Use Ctrl-C to stop
I added "logger.warn("I have the env as: #{Rails.env}" to the OmniAuthCallbacksController and it confirms:
11:40:58 web.1 | I have the env as: development
So, I'm lost.
Thanks for your help!
Darren
PS. Not too sure what how to get a "stack trace" but hope the above is what you need!
Notifications
You’re not receiving notifications from this thread.