Class: ShellSmartPayApi::ShellAPIPlatformSecurityAuthenticationController

Inherits:
BaseController
  • Object
show all
Defined in:
lib/shell_smart_pay_api/controllers/shell_api_platform_security_authentication_controller.rb

Overview

ShellAPIPlatformSecurityAuthenticationController

Constant Summary

Constants inherited from BaseController

BaseController::GLOBAL_ERRORS

Instance Attribute Summary

Attributes inherited from BaseController

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseController

#initialize, #new_api_call_builder, #new_parameter, #new_request_builder, #new_response_handler, user_agent

Constructor Details

This class inherits a constructor from ShellSmartPayApi::BaseController

Instance Method Details

#oauth_token_post(grant_type, client_id, client_secret) ⇒ AccessTokenResponse

To obtain APIGEE access token grant typee refers to the way an application gets an access token. OAuth 2.0 defines several grant types, including the authorization code flow. you will receive a client ID and a client secret. The client ID is considered public information, and is used to build login URLs, or included in Javascript source code on a page. app, you will receive a client ID and a client secret. The client ID is considered public information, and is used to build login URLs, or included in Javascript source code on a page. The client secret must be kept confidential.

Parameters:

  • grant_type (String)

    Required parameter: In OAuth 2.0, the term

  • client_id (String)

    Required parameter: After registering your app,

  • client_secret (String)

    Required parameter: After registering your

Returns:



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/shell_smart_pay_api/controllers/shell_api_platform_security_authentication_controller.rb', line 23

def oauth_token_post(grant_type,
                     client_id,
                     client_secret)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/oauth/token',
                                 Server::SHELL)
               .form_param(new_parameter(grant_type, key: 'grant_type'))
               .form_param(new_parameter(client_id, key: 'client_id'))
               .form_param(new_parameter(client_secret, key: 'client_secret'))
               .header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type'))
               .header_param(new_parameter('application/json', key: 'accept')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(AccessTokenResponse.method(:from_hash))
                .local_error('401',
                             'Unauthorized',
                             AccessTokenErrorException))
    .execute
end