Class: WorkAuthClient::Client
- Inherits:
-
Object
- Object
- WorkAuthClient::Client
- Defined in:
- lib/work_auth_client.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
TODO: Figure out best way to configure host information.
Instance Method Summary collapse
-
#access_token(request) ⇒ Object
‘access_token` makes a request to the auth server to generate an access token according to the request.
-
#verification(request) ⇒ Object
‘verification` makes a call to the authorization server in order to get verification of the access_token provided.
Instance Attribute Details
#host ⇒ Object
TODO: Figure out best way to configure host information
12 13 14 |
# File 'lib/work_auth_client.rb', line 12 def host @host end |
Instance Method Details
#access_token(request) ⇒ Object
‘access_token` makes a request to the auth server to generate an access token according to the request. Currently, the auth server only supports the following grant_types:
- client_credentials
- password
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/work_auth_client.rb', line 19 def access_token(request) validate_host if !request.is_a?(ClientCredentialsRequest) || !request.is_a?(PasswordRequest) raise ArgumentError end resp = RestClient.post("#{self.host}/access_token", request.as_json, { content_type: :json, accept: :json }) OpenStruct.new(resp) end |
#verification(request) ⇒ Object
‘verification` makes a call to the authorization server in order to get
verification of the access_token provided.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/work_auth_client.rb', line 36 def verification(request) validate_host if !request.is_a?(VerificationRequest) raise ArgumentError end resp = RestClient.post("#{self.host}/verification", request.as_json, { content_type: :json, accept: :json }) OpenStruct.new(resp) end |