-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Get extra from omniauth-facebook. #647
Comments
Ok, got it to work. I had to over write 2 functions in OmniauthCallbacksController : # intermediary route for successful omniauth authentication. omniauth does
# not support multiple models, so we must resort to this terrible hack.
def redirect_callbacks
# derive target redirect route from 'resource_class' param, which was set
# before authentication.
devise_mapping = [request.env['omniauth.params']['namespace_name'],
request.env['omniauth.params']['resource_class'].underscore.gsub('/', '_')].compact.join('_')
redirect_route = "#{request.protocol}#{request.host_with_port}/#{Devise.mappings[devise_mapping.to_sym].fullpath}/#{params[:provider]}/callback"
# preserve omniauth info for success route. ignore 'extra' in twitter
# auth response to avoid CookieOverflow.
session['dta.omniauth.auth'] = (params[:provider] == 'twitter') ? request.env['omniauth.auth'].except('extra') : request.env['omniauth.auth']
session['dta.omniauth.params'] = request.env['omniauth.params']
redirect_to redirect_route
end
protected
# break out provider attribute assignment for easy method extension
def assign_provider_attrs(user, auth_hash)
user.assign_attributes({
nickname: auth_hash['info']['nickname'],
name: auth_hash['info']['name'],
image: auth_hash['info']['image'],
email: auth_hash['info']['email'],
birthday: Date.strptime(auth_hash['extra']['raw_info']['birthday'], '%m/%d/%Y'),
gender: auth_hash['extra']['raw_info']['gender']
})
end I think this line 20 should be Now I'm wondering if I have a better option to include those extra informations inside my User model than over writing a protected |
Hi there @alain-andre , In an effort to cleanup this project and prioritize a bit, we're marking issues that haven't had any activity in a while with a "close-in-7-days" label. If we don't hear from you in about a week, we'll be closing this issue. Obviously feel free to re-open it at any time if it's the right time or this was done in error! If you are still having the issue (especially if it's a bug report) please refer to our new Issue Template to provide some more details to help us solve it. Hope all is well. |
Hi there, I'm trying to get Facebook birthday of the user identifying to save it in my User but I don't get the data.
I have set my
config/initializers/omniauth.rb
I have seen in omniauth-facebook that they collect all infos in https://github.com/mkdynamic/omniauth-facebook/blob/master/lib/omniauth/strategies/facebook.rb with this code
But I never get it in
request.env['omniauth.auth']
in OmniauthCallbacksController, I only get theinfo
.How can I get the
extra
?The text was updated successfully, but these errors were encountered: