Class: Code0::Identities::Provider::BaseOauth

Inherits:
Object
  • Object
show all
Defined in:
lib/code0/identities/provider/base_oauth.rb

Direct Known Subclasses

Discord, Github, Gitlab, Google, Microsoft

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config_loader) ⇒ BaseOauth

Returns a new instance of BaseOauth.



9
10
11
# File 'lib/code0/identities/provider/base_oauth.rb', line 9

def initialize(config_loader)
  @config_loader = config_loader
end

Instance Attribute Details

#config_loaderObject (readonly)

Returns the value of attribute config_loader.



7
8
9
# File 'lib/code0/identities/provider/base_oauth.rb', line 7

def config_loader
  @config_loader
end

Instance Method Details

#authorization_urlObject

Raises:

  • (NotImplementedError)


13
14
15
# File 'lib/code0/identities/provider/base_oauth.rb', line 13

def authorization_url
  raise NotImplementedError
end

#load_identity(**params) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/code0/identities/provider/base_oauth.rb', line 29

def load_identity(**params)
  code = params[:code]
  token, token_type = access_token code

  response = HTTParty.get(user_details_url,
                          headers: {
                            Authorization: "#{token_type} #{token}",
                            "Accept" => "application/json"
                          })

  check_response response

  create_identity response, token, token_type
end

#token_payload(code) ⇒ Object

Raises:

  • (NotImplementedError)


25
26
27
# File 'lib/code0/identities/provider/base_oauth.rb', line 25

def token_payload(code)
  raise NotImplementedError
end

#token_urlObject

Raises:

  • (NotImplementedError)


17
18
19
# File 'lib/code0/identities/provider/base_oauth.rb', line 17

def token_url
  raise NotImplementedError
end

#user_details_urlObject

Raises:

  • (NotImplementedError)


21
22
23
# File 'lib/code0/identities/provider/base_oauth.rb', line 21

def user_details_url
  raise NotImplementedError
end