I set up my app as a tutorial - If you can not access it, then my code
Omniauth control callback
def all users = User.from_omniauth (request.env ["omniauth.auth"]) If user.persisted? Flash.notice = "Sign In!" Sign_in_and_redirect user and session ["devise.user_attributes"] = user.attributes redirect_to new_user_registration_url end-end alias_method: twitter, all end user model
def Where is self.from_omniauth (auth) (auth.slice (: provider,: uid)). First_or_create do User | User.provider = auth.provider user.uid = auth.uid user.username = auth.info.nickname user.name = auth.info.name end-end self.new_with_session (parameters, session) if session ["devise.user_attributes" ] New (session ["devise.user_attributes"], without protection: true) user | User.attributes = params user.valid? Thanks
If you want to take a look at the information returned by a specific provider, then keep it as the first line of your callback controller:
raise env ["omniauth.auth"]. To_yaml You will be able to see that the information you want can be accessed in auth .credentials.token and auth.credentials.secret < / Code>. EDIT: Now that rail uses the 4th best_carms gem, this method of monitoring omniauth hash does not work so well. There is a better way now:
render: text = & gt; "& Lt; ago" + Env ["omniauth.auth"]. To_yaml and Return
No comments:
Post a Comment