Class: OAuth::GoogleAuthorizationsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/nopassword/oauth/google_authorizations_controller.rb

Constant Summary collapse

CLIENT_ID =
ENV["GOOGLE_CLIENT_ID"]
CLIENT_SECRET =
ENV["GOOGLE_CLIENT_SECRET"]
SCOPE =
"openid email profile"
AUTHORIZATION_URL =
URI("https://accounts.google.com/o/oauth2/v2/auth")
TOKEN_URL =
URI("https://www.googleapis.com/oauth2/v4/token")
USER_INFO_URL =
URI("https://www.googleapis.com/oauth2/v3/userinfo")

Instance Method Summary collapse

Instance Method Details

#createObject



13
14
15
# File 'app/controllers/nopassword/oauth/google_authorizations_controller.rb', line 13

def create
  redirect_to authorization_url.to_s, allow_other_host: true
end

#showObject



17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/controllers/nopassword/oauth/google_authorizations_controller.rb', line 17

def show
  access_token = request_access_token.parse.fetch("access_token")
   = (access_token: access_token).parse

  if .any?
    Rails.logger.info "Authorization #{self.class} succeeded"
    authorization_succeeded 
  else
    Rails.logger.info "Authorization #{self.class} failed"
    authorization_failed
  end
end