Class: Vonage::NetworkAuthentication::ServerAuthentication

Inherits:
Vonage::Namespace
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/vonage/network_authentication/server_authentication.rb

Instance Method Summary collapse

Instance Method Details

#bc_authorize(purpose:, api_scope:, login_hint:) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/vonage/network_authentication/server_authentication.rb', line 24

def bc_authorize(purpose:, api_scope:, login_hint:)
  scope = "openid dpv:#{purpose}##{api_scope}"
  request(
    "/oauth2/bc-authorize",
    params: {
      scope: scope,
      login_hint: 
    },
    type: Post
  )
end

#request_access_token(auth_req_id:) ⇒ Object



36
37
38
39
40
41
42
43
44
45
# File 'lib/vonage/network_authentication/server_authentication.rb', line 36

def request_access_token(auth_req_id:)
  request(
    "/oauth2/token",
    params: {
      grant_type: 'urn:openid:params:grant-type:ciba',
      auth_req_id: auth_req_id
    },
    type: Post
  )
end

#token(purpose:, api_scope:, login_hint:, **params) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/vonage/network_authentication/server_authentication.rb', line 14

def token(purpose:, api_scope:, login_hint:, **params)
  auth_req_id = bc_authorize(
    purpose: purpose,
    api_scope: api_scope,
    login_hint: 
  ).auth_req_id

  request_access_token(auth_req_id: auth_req_id).access_token
end