angularjs - How to access Devise_token_auth access token of omniauth provider? -
how access access token of omniauth provider should sent after successful authentication devise_token_auth gem , ng-token-auth angular? i'd store token make future requests omniauth provider updating information. omniauth provider strava. see devise_token_auth creating own access tokens, aren't accessing strava. have no idea devise token auth pulls in information strava after reading through gem's code. seems should pretty simple thing, can't 1 wants information returned. in advance.
we have been able figure out lot of experimentation. @resouce
return nil too, did find access-token , other information returned omniauth provider, located in request.env['omniauth.auth']
, located in redirect_callbacks
action of omniauthcallbacks
controller. needed set up
mount_devise_token_auth_for 'user', at: 'auth', controllers: { omniauth_callbacks: 'registrations'}
in routes.rb
, , create custom controller named registrationscontroller.
so our block looked this
class registrationscontroller < devisetokenauth::omniauthcallbackscontroller def redirect_callbacks super puts "redirect:" puts request.env['omniauth.params'] puts "auth info" puts request.env['omniauth.auth'].credentials['token'] puts "redirect end" # create user_strava_key , save it. @strava_token = request.env['omniauth.auth'].credentials['token'] userstravakey.create(key_secret: @strava_token) end end
Comments
Post a Comment