Class: FIS::Auth::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/fis/auth/client.rb

Overview

OAuth2 + PKCE helper class for authenticating against portal.flatironschool.com

Constant Summary collapse

CODE_CHALLENGE_METHOD =
'S256'

Instance Method Summary collapse

Constructor Details

#initializeClient

Returns a new instance of Client.



12
13
14
15
16
17
18
19
# File 'lib/fis/auth/client.rb', line 12

def initialize
  @client = OAuth2::Client.new(
    Auth::CLIENT_ID,
    nil,
    site: Auth::PROVIDER_URL,
    redirect_uri: Auth::REDIRECT_URI
  )
end

Instance Method Details

#authorize_urlObject



21
22
23
24
25
26
# File 'lib/fis/auth/client.rb', line 21

def authorize_url
  @client.auth_code.authorize_url(
    code_challenge: code_challenge,
    code_challenge_method: CODE_CHALLENGE_METHOD
  )
end

#get_token(code:) ⇒ Object



28
29
30
# File 'lib/fis/auth/client.rb', line 28

def get_token(code:)
  @client.auth_code.get_token(code, code_verifier: code_verifier)
end