Class: MultiAuthSample::OAuthAuthorizationController

Inherits:
BaseController show all
Defined in:
lib/multi_auth_sample/controllers/o_auth_authorization_controller.rb

Overview

OAuthAuthorizationController

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 MultiAuthSample::BaseController

Instance Method Details

#refresh_token_o_auth_acg(authorization, refresh_token, scope: nil, _field_parameters: nil) ⇒ OAuthToken

Obtain a new access token using a refresh token Basic auth format space-delimited list. supported by this endpoint.

Parameters:

  • authorization (String)

    Required parameter: Authorization header in

  • refresh_token (String)

    Required parameter: Refresh token

  • scope (String) (defaults to: nil)

    Optional parameter: Requested scopes as a

  • _field_parameters (Hash) (defaults to: nil)

    Additional optional form parameters are

Returns:



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/multi_auth_sample/controllers/o_auth_authorization_controller.rb', line 86

def refresh_token_o_auth_acg(authorization,
                             refresh_token,
                             scope: nil,
                             _field_parameters: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/oauth2/non-auth-server/token',
                                 Server::DEFAULT)
               .form_param(new_parameter('refresh_token', key: 'grant_type'))
               .header_param(new_parameter(authorization, key: 'Authorization'))
               .form_param(new_parameter(refresh_token, key: 'refresh_token'))
               .form_param(new_parameter(scope, key: 'scope'))
               .header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .additional_form_params(_field_parameters))
    .response(new_response_handler
               .deserializer(APIHelper.method(:custom_type_deserializer))
               .deserialize_into(OAuthToken.method(:from_hash))
               .local_error('400',
                            'OAuth 2 provider returned an error.',
                            OAuthProviderException)
               .local_error('401',
                            'OAuth 2 provider says client authentication failed.',
                            OAuthProviderException))
    .execute
end

#refresh_token_o_auth_ropcg(authorization, refresh_token, scope: nil, _field_parameters: nil) ⇒ OAuthToken

Obtain a new access token using a refresh token Basic auth format space-delimited list. supported by this endpoint.

Parameters:

  • authorization (String)

    Required parameter: Authorization header in

  • refresh_token (String)

    Required parameter: Refresh token

  • scope (String) (defaults to: nil)

    Optional parameter: Requested scopes as a

  • _field_parameters (Hash) (defaults to: nil)

    Additional optional form parameters are

Returns:



161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
# File 'lib/multi_auth_sample/controllers/o_auth_authorization_controller.rb', line 161

def refresh_token_o_auth_ropcg(authorization,
                               refresh_token,
                               scope: nil,
                               _field_parameters: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/oauth2/non-auth-server/token',
                                 Server::DEFAULT)
               .form_param(new_parameter('refresh_token', key: 'grant_type'))
               .header_param(new_parameter(authorization, key: 'Authorization'))
               .form_param(new_parameter(refresh_token, key: 'refresh_token'))
               .form_param(new_parameter(scope, key: 'scope'))
               .header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .additional_form_params(_field_parameters))
    .response(new_response_handler
               .deserializer(APIHelper.method(:custom_type_deserializer))
               .deserialize_into(OAuthToken.method(:from_hash))
               .local_error('400',
                            'OAuth 2 provider returned an error.',
                            OAuthProviderException)
               .local_error('401',
                            'OAuth 2 provider says client authentication failed.',
                            OAuthProviderException))
    .execute
end

#request_token_o_auth_acg(authorization, code, redirect_uri, _field_parameters: nil) ⇒ OAuthToken

Create a new OAuth 2 token. Basic auth format supported by this endpoint.

Parameters:

  • authorization (String)

    Required parameter: Authorization header in

  • code (String)

    Required parameter: Authorization Code

  • redirect_uri (String)

    Required parameter: Redirect Uri

  • _field_parameters (Hash) (defaults to: nil)

    Additional optional form parameters are

Returns:



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/multi_auth_sample/controllers/o_auth_authorization_controller.rb', line 50

def request_token_o_auth_acg(authorization,
                             code,
                             redirect_uri,
                             _field_parameters: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/oauth2/non-auth-server/token',
                                 Server::DEFAULT)
               .form_param(new_parameter('authorization_code', key: 'grant_type'))
               .header_param(new_parameter(authorization, key: 'Authorization'))
               .form_param(new_parameter(code, key: 'code'))
               .form_param(new_parameter(redirect_uri, key: 'redirect_uri'))
               .header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .additional_form_params(_field_parameters))
    .response(new_response_handler
               .deserializer(APIHelper.method(:custom_type_deserializer))
               .deserialize_into(OAuthToken.method(:from_hash))
               .local_error('400',
                            'OAuth 2 provider returned an error.',
                            OAuthProviderException)
               .local_error('401',
                            'OAuth 2 provider says client authentication failed.',
                            OAuthProviderException))
    .execute
end

#request_token_o_auth_ccg(authorization, scope: nil, _field_parameters: nil) ⇒ OAuthToken

Create a new OAuth 2 token. Basic auth format space-delimited list. supported by this endpoint.

Parameters:

  • authorization (String)

    Required parameter: Authorization header in

  • scope (String) (defaults to: nil)

    Optional parameter: Requested scopes as a

  • _field_parameters (Hash) (defaults to: nil)

    Additional optional form parameters are

Returns:



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/multi_auth_sample/controllers/o_auth_authorization_controller.rb', line 17

def request_token_o_auth_ccg(authorization,
                             scope: nil,
                             _field_parameters: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/request_token',
                                 Server::AUTH)
               .form_param(new_parameter('client_credentials', key: 'grant_type'))
               .header_param(new_parameter(authorization, key: 'Authorization'))
               .form_param(new_parameter(scope, key: 'scope'))
               .header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .additional_form_params(_field_parameters))
    .response(new_response_handler
               .deserializer(APIHelper.method(:custom_type_deserializer))
               .deserialize_into(OAuthToken.method(:from_hash))
               .local_error('400',
                            'OAuth 2 provider returned an error.',
                            OAuthProviderException)
               .local_error('401',
                            'OAuth 2 provider says client authentication failed.',
                            OAuthProviderException))
    .execute
end

#request_token_o_auth_ropcg(authorization, username, password, scope: nil, _field_parameters: nil) ⇒ OAuthToken

Create a new OAuth 2 token. Basic auth format space-delimited list. supported by this endpoint.

Parameters:

  • authorization (String)

    Required parameter: Authorization header in

  • username (String)

    Required parameter: Resource owner username

  • password (String)

    Required parameter: Resource owner password

  • scope (String) (defaults to: nil)

    Optional parameter: Requested scopes as a

  • _field_parameters (Hash) (defaults to: nil)

    Additional optional form parameters are

Returns:



123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/multi_auth_sample/controllers/o_auth_authorization_controller.rb', line 123

def request_token_o_auth_ropcg(authorization,
                               username,
                               password,
                               scope: nil,
                               _field_parameters: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/oauth2/non-auth-server/token',
                                 Server::DEFAULT)
               .form_param(new_parameter('password', key: 'grant_type'))
               .header_param(new_parameter(authorization, key: 'Authorization'))
               .form_param(new_parameter(username, key: 'username'))
               .form_param(new_parameter(password, key: 'password'))
               .form_param(new_parameter(scope, key: 'scope'))
               .header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .additional_form_params(_field_parameters))
    .response(new_response_handler
               .deserializer(APIHelper.method(:custom_type_deserializer))
               .deserialize_into(OAuthToken.method(:from_hash))
               .local_error('400',
                            'OAuth 2 provider returned an error.',
                            OAuthProviderException)
               .local_error('401',
                            'OAuth 2 provider says client authentication failed.',
                            OAuthProviderException))
    .execute
end