Skip to content

Commit

Permalink
Merge pull request #16 from mattvv/master
Browse files Browse the repository at this point in the history
Facebook Login
  • Loading branch information
adelevie committed Mar 23, 2012
2 parents 24cccb9 + b48ded0 commit 4c96d4c
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions lib/parse_user.rb
Expand Up @@ -23,4 +23,29 @@ def self.authenticate(username, password)
end

end

def self.authenticate_with_facebook(user_id, access_token, expires)
base_uri = "https://api.parse.com/1/users"
app_id = settings['app_id']
master_key = settings['master_key']
resource = RestClient::Resource.new(base_uri, app_id, master_key)

begin
resp = resource.post(
{ "authData" =>
{ "facebook" =>
{
"id" => user_id,
"access_token" => access_token,
"expiration_date" => Time.now + expires.to_i
}
}
}.to_json,
:content_type => 'application/json', :accept => :json)
user = model_name.constantize.new(JSON.parse(resp), false)
user
rescue
false
end
end
end

0 comments on commit 4c96d4c

Please sign in to comment.