Last active
December 15, 2015 21:49
-
-
Save tsycho/5328714 to your computer and use it in GitHub Desktop.
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
class OAuthController < ApplicationController | |
def authenticate | |
oauth_token = params[:oauth_token] | |
oauth_verifier = params[:oauth_verifier] | |
@user = User.find_by_oauth_token(oauth_token) | |
if !@user | |
# Do something appropriate, such as a 404 | |
else | |
begin | |
oauth_tokens = get_access_token(oauth_token, @user.oauth_token_secret, oauth_verifier) | |
# Update @user, save oauth_tokens in the database (in a secure way) | |
rescue Exception => e | |
# Something went wrong, or user did not give you permissions on Gmail | |
# Do something appropriate, potentially try again? | |
flash[:error] = "There was an error while authenticating with Gmail. Please try again." | |
end | |
redirect_to root_url | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment