Class: NoPassword::OAuth::GithubAuthorizationsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- NoPassword::OAuth::GithubAuthorizationsController
- Includes:
- Routable
- Defined in:
- app/controllers/nopassword/oauth/github_authorizations_controller.rb
Overview
Implements OAuth flow as described at https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/authorizing-oauth-apps
Constant Summary collapse
- AUTHORIZATION_URL =
URI("https://github.com/login/oauth/authorize")
- TOKEN_URL =
URI("https://github.com/login/oauth/access_token")
- USER_URL =
URI("https://api.github.com/user")
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.scope ⇒ Object
8 |
# File 'app/controllers/nopassword/oauth/github_authorizations_controller.rb', line 8 def self.scope = "read:user user:email" |
Instance Method Details
#create ⇒ Object
19 20 21 |
# File 'app/controllers/nopassword/oauth/github_authorizations_controller.rb', line 19 def create redirect_to .to_s, allow_other_host: true end |
#show ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/controllers/nopassword/oauth/github_authorizations_controller.rb', line 23 def show access_token = request_access_token.parse.fetch("access_token") user_info = request_user_info(access_token: access_token).parse if user_info.any? Rails.logger.info "Authorization #{self.class} succeeded" user_info else Rails.logger.info "Authorization #{self.class} failed" end end |