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_tokenmakes a request to the auth server to generate an access token according to the request. -
#verification(request) ⇒ Object
verificationmakes 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
11 12 13 |
# File 'lib/work_auth_client.rb', line 11 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
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/work_auth_client.rb', line 18 def access_token(request) validate_host if !request.is_a?(ClientCredentialsRequest) || !request.is_a?(PasswordRequest) raise ArgumentError end RestClient.post("#{self.host}/access_token", request.as_json, { content_type: :json, accept: :json }) end |
#verification(request) ⇒ Object
verification makes a call to the authorization server in order to get
verification of the access_token provided.
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/work_auth_client.rb', line 33 def verification(request) validate_host if !request.is_a?(ClientCredentialsRequest) || !request.is_a?(PasswordRequest) raise ArgumentError end RestClient.post("#{self.host}/access_token", request.as_json, { content_type: :json, accept: :json }) end |