Module: Sorcery::Controller::Submodules::External::Providers::Github::GithubClient
- Includes:
- Base::BaseClient
- Defined in:
- lib/sorcery/controller/submodules/external/providers/github.rb
Class Attribute Summary collapse
-
.access_token ⇒ Object
readonly
Returns the value of attribute access_token.
-
.auth_path ⇒ Object
Returns the value of attribute auth_path.
-
.callback_url ⇒ Object
Returns the value of attribute callback_url.
-
.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.
-
.token_path ⇒ Object
Returns the value of attribute token_path.
-
.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
- .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_token ⇒ Object (readonly)
Returns the value of attribute access_token.
42 43 44 |
# File 'lib/sorcery/controller/submodules/external/providers/github.rb', line 42 def access_token @access_token end |
.auth_path ⇒ Object
Returns the value of attribute auth_path.
32 33 34 |
# File 'lib/sorcery/controller/submodules/external/providers/github.rb', line 32 def auth_path @auth_path end |
.callback_url ⇒ Object
Returns the value of attribute callback_url.
32 33 34 |
# File 'lib/sorcery/controller/submodules/external/providers/github.rb', line 32 def callback_url @callback_url end |
.key ⇒ Object
Returns the value of attribute key.
32 33 34 |
# File 'lib/sorcery/controller/submodules/external/providers/github.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/github.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/github.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/github.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/github.rb', line 32 def state @state end |
.token_path ⇒ Object
Returns the value of attribute token_path.
32 33 34 |
# File 'lib/sorcery/controller/submodules/external/providers/github.rb', line 32 def token_path @token_path end |
.user_info_mapping ⇒ Object
Returns the value of attribute user_info_mapping.
32 33 34 |
# File 'lib/sorcery/controller/submodules/external/providers/github.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/github.rb', line 32 def user_info_path @user_info_path end |
Class Method Details
.get_user_hash(access_token) ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/sorcery/controller/submodules/external/providers/github.rb', line 55 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
63 64 65 |
# File 'lib/sorcery/controller/submodules/external/providers/github.rb', line 63 def has_callback? true end |
.init ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'lib/sorcery/controller/submodules/external/providers/github.rb', line 46 def init @site = "https://github.com/" @user_info_path = "https://api.github.com/user" @scope = nil @auth_path = "/login/oauth/authorize" @token_path = "/login/oauth/access_token" @user_info_mapping = {} 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.
69 70 71 |
# File 'lib/sorcery/controller/submodules/external/providers/github.rb', line 69 def login_url(params,session) self.({:authorize_url => @auth_path}) end |
.process_callback(params, session) ⇒ Object
tries to login the user from access token
74 75 76 77 78 79 80 81 82 |
# File 'lib/sorcery/controller/submodules/external/providers/github.rb', line 74 def process_callback(params,session) args = {} args.merge!({:code => params[:code]}) if params[:code] = { :token_url => @token_path, :token_method => :post } return self.get_access_token(args, ) end |