Created
August 17, 2011 14:45
-
-
Save markoa/1151655 to your computer and use it in GitHub Desktop.
Saving LinkedIn OAuth data in a callback action (Rails controller, Devise, Omniauth).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# in your routes.rb: | |
# devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" } | |
# | |
# and view: | |
# link_to("Connect to LinkedIn", user_omniauth_authorize_path(:linked_in)) | |
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController | |
def linkedin | |
omniauth_hash = env["omniauth.auth"] | |
current_user.create_linkedin_connection( | |
:token => omniauth_hash["extra"]["access_token"].token, | |
:secret => omniauth_hash["extra"]["access_token"].secret, | |
:uid => omniauth_hash["uid"] | |
) | |
redirect_to root_path, :notice => "You've successfully connected your LinkedIn account." | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment