Permalink
Browse files

Merge pull request #41 from isuda/fb_exchange_token

Added method to replace offline_access.
  • Loading branch information...
treeder committed Oct 9, 2012
2 parents bd0afbe + 449341a commit 36a994d15c9acd32c11c696fe052f0643aab4d76
Showing with 18 additions and 0 deletions.
  1. +18 −0 lib/mini_fb.rb
View
@@ -518,6 +518,24 @@ def self.oauth_access_token(app_id, redirect_uri, secret, code)
return params
end
+ # returns a hash with one value being 'access_token', the other being 'expires'
+ def self.fb_exchange_token(app_id, secret, access_token)
+ oauth_url = "#{graph_base}oauth/access_token"
+ oauth_url << "?client_id=#{app_id}"
+ oauth_url << "&client_secret=#{secret}"
+ oauth_url << "&grant_type=fb_exchange_token"
+ oauth_url << "&fb_exchange_token=#{CGI.escape(access_token)}"
+ resp = RestClient.get oauth_url
+ puts 'resp=' + resp.body.to_s if @@logging
+ params = {}
+ params_array = resp.split("&")
+ params_array.each do |p|
+ ps = p.split("=")
+ params[ps[0]] = ps[1]
+ end
+ return params
+ end
+
# Return a JSON object of working Oauth tokens from working session keys, returned in order given
def self.oauth_exchange_session(app_id, secret, session_keys)
url = "#{graph_base}oauth/exchange_sessions"

0 comments on commit 36a994d

Please sign in to comment.