app/controllers/google_controller.rb
##
# Ensure valid credentials, either by restoring from the saved credentials
# files or intitiating an OAuth2 authorization. If authorization is required,
# the user's default browser will be launched to approve the request.
#
# @return [Google::Auth::UserRefreshCredentials] OAuth2 credentials
Ensure valid credentials, either by restoring from the saved credentials
files or intitiating an OAuth2 authorization. If authorization is required,
the user's default browser will be launched to approve the request.
Ensure valid credentials either by restoring from the saved credentials files or intitiating an OAuth2 authorization . If authorization is required the user ' s default browser will be launched to approve the request .
def authorize(force_reload)
    FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))
    client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)
    token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)
    authorizer = Google::Auth::UserAuthorizer.new(
        client_id, SCOPE, token_store)
    user_id = 'default'
    credentials = authorizer.get_credentials(user_id)
    if force_reload || credentials.nil?
      session[:is_authorized] = false
      redirect_to google_fetch_path
      return
    end
    credentials
  end
def authorize ( force_reload ) FileUtils . mkdir_p ( File . dirname ( CREDENTIALS_PATH ) ) client_id = Google :: Auth :: ClientId . from_file ( CLIENT_SECRETS_PATH ) token_store = Google :: Auth :: Stores :: FileTokenStore . new ( file : CREDENTIALS_PATH ) authorizer = Google :: Auth :: UserAuthorizer . new ( client_id , SCOPE , token_store ) user_id = 'default' credentials = authorizer . get_credentials ( user_id ) if force_reload || credentials . nil? session [ :is_authorized ] = false redirect_to google_fetch_path return end credentials end
Ensure valid credentials, either by restoring from the saved credentials
files or intitiating an OAuth2 authorization.
Ensure valid credentials either by restoring from the saved credentials files or intitiating an OAuth2 authorization .
None
Google::Auth::UserRefreshCredentials
force_reload