Forked from bryanl/gist:1245433
Created
September 27, 2011 15:57
Star
You must be signed in to star a gist
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 TwitterReverseAuthController < ApplicationController | |
def api_key_exchange | |
user_credentials = UserCredentials.new(params.slice(:screen_name, :token, :secret)) | |
if user_credentials.valid? | |
user = user_credentials.user | |
token = params[:token] | |
device = Device.find_or_create_by_token!(params.slice(:token, :description).merge(:user_id => @user.id)) | |
render :json => { :api_key => device.api_key } | |
else | |
render :json => { :error => user_credentials.first_error}, :status => :unprocessable_entity } | |
end | |
end | |
end | |
class UserCredentials | |
def initialize(screen_name, token, secret) | |
# ... | |
end | |
def valid? | |
# ... | |
end | |
def first_error | |
# ... | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment