Method: FbGraph::Auth#from_cookie

Defined in:
lib/fb_graph/auth.rb


31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/fb_graph/auth.rb', line 31

def from_cookie(cookie)

  #this creates a cookie
  cookie = FbGraph::Auth::Cookie.parse(self.client, cookie)

  #the cookie expires time is the time as an integer
  #in the oauth2 api, it does Time.now + expires, creating a time too large
  #instead, make expires a delta value
  time_expires = cookie[:expires].to_i - Time.now.to_i
  self.access_token = OAuth2::AccessToken.new(
    self.client,
    cookie[:access_token],
    cookie[:refresh_token],
    time_expires
  )
  self.user = FbGraph::User.new(cookie[:uid], :access_token => self.access_token)
  self
end