Class: FbGraph2::Auth
- Inherits:
-
Rack::OAuth2::Client
- Object
- Rack::OAuth2::Client
- FbGraph2::Auth
show all
- Defined in:
- lib/fb_graph2/auth.rb,
lib/fb_graph2/auth/signed_request.rb
Defined Under Namespace
Classes: Grant, SignedRequest
Instance Method Summary
collapse
Constructor Details
#initialize(client_id, client_secret, options = {}) ⇒ Auth
Returns a new instance of Auth.
9
10
11
12
13
14
15
16
17
|
# File 'lib/fb_graph2/auth.rb', line 9
def initialize(client_id, client_secret, options = {})
super options.merge(
identifier: client_id,
secret: client_secret,
host: URI.parse(FbGraph2.root_url).host,
authorization_endpoint: File.join('/', FbGraph2.api_version, '/oauth/authorize'),
token_endpoint: File.join('/', FbGraph2.api_version, '/oauth/access_token')
)
end
|
Instance Method Details
#access_token!(options = {}) ⇒ Object
25
26
27
28
29
30
31
|
# File 'lib/fb_graph2/auth.rb', line 25
def access_token!(options = {})
super options.merge(
client_auth_method: :body
)
rescue Rack::OAuth2::Client::Error => e
raise Exception.detect(e.status, e.response)
end
|
#debug_token!(input_token) ⇒ Object
33
34
35
36
37
38
39
|
# File 'lib/fb_graph2/auth.rb', line 33
def debug_token!(input_token)
token_metadata = TokenMetadata.new
token_metadata.authenticate access_token!
token_metadata.fetch(
input_token: input_token.to_s
)
end
|
#fb_exchange_token=(access_token) ⇒ Object
19
20
21
22
23
|
# File 'lib/fb_graph2/auth.rb', line 19
def fb_exchange_token=(access_token)
@grant = Grant::FbExchangeToken.new(
fb_exchange_token: access_token
)
end
|
#from_cookie(cookie) ⇒ Object
41
42
43
44
45
46
47
48
49
|
# File 'lib/fb_graph2/auth.rb', line 41
def from_cookie(cookie)
token = case cookie
when String
cookie
else
cookie["fbsr_#{identifier}"]
end
from_signed_request token
end
|
#from_signed_request(token) ⇒ Object
51
52
53
|
# File 'lib/fb_graph2/auth.rb', line 51
def from_signed_request(token)
SignedRequest.new(token).verify! self
end
|