Class: LogaltyCertificateIssuanceApiCerty::AuthenticationApi
- Defined in:
- lib/logalty_certificate_issuance_api_certy/apis/authentication_api.rb
Overview
AuthenticationApi
Constant Summary
Constants inherited from BaseApi
Instance Attribute Summary
Attributes inherited from BaseApi
Instance Method Summary collapse
-
#get_token(grant_type, scope) ⇒ ApiResponse
Authenticate using the OAuth2 ‘client_credentials` grant to obtain a Bearer token.
Methods inherited from BaseApi
#initialize, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters
Constructor Details
This class inherits a constructor from LogaltyCertificateIssuanceApiCerty::BaseApi
Instance Method Details
#get_token(grant_type, scope) ⇒ ApiResponse
Authenticate using the OAuth2 ‘client_credentials` grant to obtain a Bearer token. Credentials must be Base64-encoded as `Base64(<client_id>:<client_secret>)` and passed in the `Authorization` header. value `client_credentials`. issuance. Fixed value `certy/certificate-request`.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/logalty_certificate_issuance_api_certy/apis/authentication_api.rb', line 19 def get_token(grant_type, scope) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/oauth2/token', Server::DEFAULT) .form_param(new_parameter(grant_type, key: 'grant_type') .is_required(true)) .form_param(new_parameter(scope, key: 'scope') .is_required(true)) .header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type')) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('basicAuth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(TokenResponse.method(:from_hash)) .is_api_response(true)) .execute end |