You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a rails-api app and I added the gem 'omniauth-google-oauth2' . Everything is working fine up to showing an oauth screen and then clicking next to signup and the user is also saved into the db as well. But after that, I get an err saying 'Either signup or log in'. This is happening because I have a before_action :authenticate_api_employee! on my controllers.
I did some research and found out that the current_api_employee is nil as well. Any idea how this can be fixed?
I have overridden the omniauth_callbacks_controller and added a debugger there and current_api_employee have a value but it s value is set to nil after I am signed in and redirected.
Do i need to add ?origin=http:/..... to the oauth url ? It looks like the omniauth_success needs that url to redirect properly but I am overriding the omniauth_success method.
Would really appreciate your help
My ApplicationController is extending from ActionController::API .
My Omniauth controller
module Overrides
class OmniauthCallbacksController < DeviseTokenAuth::OmniauthCallbacksController
def omniauth_success
super do |resource|
if omniauth_window_type.present? # auth requested from angular
sign_in resource
else # if backend standalone auth
redirect_to '/test' and return
# sign_in_and_redirect test_path and return
end
end
end
# break out provider attribute assignment for easy method extension
def assign_provider_attrs(user, auth_hash)
user.assign_attributes({
email: auth_hash['info']['email'],
name: auth_hash['info']['name'],
admin: true,
first_name: CustomRegex.japanese?(auth_hash['info']["first_name"]) ? '' : auth_hash['info']["first_name"],
last_name: CustomRegex.japanese?(auth_hash['info']["last_name"]) ? '' : auth_hash['info']["last_name"],
uqid: SecureRandom.uuid,
company_id: 1,
timeline: 0
})
end
end
end
@zachfeldman i made a very rookie mistake. After I was redirected to auth_origin_url with tokens I used that token and sent it in the header to make a call to my apis.
I have a rails-api app and I added the
gem 'omniauth-google-oauth2'
. Everything is working fine up to showing an oauth screen and then clicking next to signup and the user is also saved into the db as well. But after that, I get an err saying 'Either signup or log in'. This is happening because I have abefore_action :authenticate_api_employee!
on my controllers.I did some research and found out that the
current_api_employee
is nil as well. Any idea how this can be fixed?I have overridden the omniauth_callbacks_controller and added a debugger there and current_api_employee have a value but it s value is set to nil after I am signed in and redirected.
Do i need to add
?origin=http:/.....
to the oauth url ? It looks like the omniauth_success needs that url to redirect properly but I am overriding the omniauth_success method.Would really appreciate your help
My
ApplicationController
is extending fromActionController::API
.My Omniauth controller
My Gemfile
The text was updated successfully, but these errors were encountered: