Class: Fb::Auth

Inherits:
Object
  • Object
show all
Defined in:
lib/fb/auth.rb,
lib/fb/auth/version.rb

Overview

Provides methods to authenticate a user with the Facebook OAuth flow.

Constant Summary collapse

VERSION =

Returns the SemVer-compatible gem version.

Returns:

  • (String)

    the SemVer-compatible gem version.

See Also:

"0.1.3"

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Auth

Returns a new instance of Auth.

Parameters:

  • options (Hash) (defaults to: {})

    the options to initialize an instance of Fb::Auth.

  • [String] (Hash)

    a customizable set of options



17
18
19
20
# File 'lib/fb/auth.rb', line 17

def initialize(options = {})
  @redirect_uri = options[:redirect_uri]
  @code = options[:code]
end

Instance Method Details

#access_tokenString

Returns the non-expiring access token of an authenticated Facebook account.

Returns:

  • (String)

    the non-expiring access token of an authenticated Facebook account.



28
29
30
31
32
# File 'lib/fb/auth.rb', line 28

def access_token
  response_body = Fb::Request.new(path: '/oauth/access_token',
  params: long_term_token_params).run
  response_body["access_token"]
end

#urlString

Returns a url to Facebook’s account authentication.

Returns:

  • (String)

    a url to Facebook’s account authentication.



23
24
25
# File 'lib/fb/auth.rb', line 23

def url
  Fb::Request.new(url_options).url
end