Module: Sorcery::Controller::Submodules::External::Providers::Facebook::FacebookClient
- Includes:
- Base::BaseClient
- Defined in:
- lib/sorcery/controller/submodules/external/providers/facebook.rb
Class Attribute Summary collapse
-
.access_permissions ⇒ Object
Returns the value of attribute access_permissions.
-
.access_token ⇒ Object
readonly
Returns the value of attribute access_token.
-
.callback_url ⇒ Object
Returns the value of attribute callback_url.
-
.display ⇒ Object
Returns the value of attribute display.
-
.key ⇒ Object
Returns the value of attribute key.
-
.scope ⇒ Object
Returns the value of attribute scope.
-
.secret ⇒ Object
Returns the value of attribute secret.
-
.site ⇒ Object
Returns the value of attribute site.
-
.state ⇒ Object
Returns the value of attribute state.
-
.user_info_mapping ⇒ Object
Returns the value of attribute user_info_mapping.
-
.user_info_path ⇒ Object
Returns the value of attribute user_info_path.
Class Method Summary collapse
-
.authorize_url ⇒ Object
overrides oauth2#authorize_url to allow customized scope.
- .get_user_hash(access_token) ⇒ Object
- .has_callback? ⇒ Boolean
- .init ⇒ Object
-
.login_url(params, session) ⇒ Object
calculates and returns the url to which the user should be redirected, to get authenticated at the external provider’s site.
-
.process_callback(params, session) ⇒ Object
tries to login the user from access token.
Methods included from Sorcery::Controller::Submodules::External::Protocols::Oauth2
authorize_url, build_client, get_access_token, oauth_version
Methods included from Base::BaseClient
Class Attribute Details
.access_permissions ⇒ Object
Returns the value of attribute access_permissions.
32 33 34 |
# File 'lib/sorcery/controller/submodules/external/providers/facebook.rb', line 32 def @access_permissions end |
.access_token ⇒ Object (readonly)
Returns the value of attribute access_token.
42 43 44 |
# File 'lib/sorcery/controller/submodules/external/providers/facebook.rb', line 42 def access_token @access_token end |
.callback_url ⇒ Object
Returns the value of attribute callback_url.
32 33 34 |
# File 'lib/sorcery/controller/submodules/external/providers/facebook.rb', line 32 def callback_url @callback_url end |
.display ⇒ Object
Returns the value of attribute display.
32 33 34 |
# File 'lib/sorcery/controller/submodules/external/providers/facebook.rb', line 32 def display @display end |
.key ⇒ Object
Returns the value of attribute key.
32 33 34 |
# File 'lib/sorcery/controller/submodules/external/providers/facebook.rb', line 32 def key @key end |
.scope ⇒ Object
Returns the value of attribute scope.
32 33 34 |
# File 'lib/sorcery/controller/submodules/external/providers/facebook.rb', line 32 def scope @scope end |
.secret ⇒ Object
Returns the value of attribute secret.
32 33 34 |
# File 'lib/sorcery/controller/submodules/external/providers/facebook.rb', line 32 def secret @secret end |
.site ⇒ Object
Returns the value of attribute site.
32 33 34 |
# File 'lib/sorcery/controller/submodules/external/providers/facebook.rb', line 32 def site @site end |
.state ⇒ Object
Returns the value of attribute state.
32 33 34 |
# File 'lib/sorcery/controller/submodules/external/providers/facebook.rb', line 32 def state @state end |
.user_info_mapping ⇒ Object
Returns the value of attribute user_info_mapping.
32 33 34 |
# File 'lib/sorcery/controller/submodules/external/providers/facebook.rb', line 32 def user_info_mapping @user_info_mapping end |
.user_info_path ⇒ Object
Returns the value of attribute user_info_path.
32 33 34 |
# File 'lib/sorcery/controller/submodules/external/providers/facebook.rb', line 32 def user_info_path @user_info_path end |
Class Method Details
.authorize_url ⇒ Object
overrides oauth2#authorize_url to allow customized scope.
77 78 79 80 |
# File 'lib/sorcery/controller/submodules/external/providers/facebook.rb', line 77 def @scope = self..present? ? self..join(",") : @scope super end |
.get_user_hash(access_token) ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/sorcery/controller/submodules/external/providers/facebook.rb', line 58 def get_user_hash(access_token) user_hash = {} response = access_token.get(@user_info_path) user_hash[:user_info] = JSON.parse(response.body) user_hash[:uid] = user_hash[:user_info]['id'] user_hash end |
.has_callback? ⇒ Boolean
66 67 68 |
# File 'lib/sorcery/controller/submodules/external/providers/facebook.rb', line 66 def has_callback? true end |
.init ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/sorcery/controller/submodules/external/providers/facebook.rb', line 46 def init @site = "https://graph.facebook.com" @user_info_path = "/me" @scope = "email,offline_access" @user_info_mapping = {} @display = "page" @token_url = "oauth/access_token" @mode = :query @parse = :query @param_name = "access_token" end |
.login_url(params, session) ⇒ Object
calculates and returns the url to which the user should be redirected, to get authenticated at the external provider’s site.
72 73 74 |
# File 'lib/sorcery/controller/submodules/external/providers/facebook.rb', line 72 def login_url(params,session) self. end |
.process_callback(params, session) ⇒ Object
tries to login the user from access token
83 84 85 86 87 88 |
# File 'lib/sorcery/controller/submodules/external/providers/facebook.rb', line 83 def process_callback(params,session) args = {} = { :token_url => @token_url, :mode => @mode, :param_name => @param_name, :parse => @parse } args.merge!({:code => params[:code]}) if params[:code] return self.get_access_token(args, ) end |