Class: Spatio::OAuthApi

Inherits:
Object
  • Object
show all
Defined in:
lib/spatio-sdk/api/o_auth_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ OAuthApi

Returns a new instance of OAuthApi.



19
20
21
# File 'lib/spatio-sdk/api/o_auth_api.rb', line 19

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/spatio-sdk/api/o_auth_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#get_jwks(opts = {}) ⇒ JWKS

JSON Web Key Set for id_token verification (RFC 7517). The set of public keys RPs use to verify Spatio-issued id_tokens. Cached for 5 minutes at the edge. Always includes the currently-active signing key plus any retired keys that may still be in circulation (id_token TTL is 1 hour + slack).

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



26
27
28
29
# File 'lib/spatio-sdk/api/o_auth_api.rb', line 26

def get_jwks(opts = {})
  data, _status_code, _headers = get_jwks_with_http_info(opts)
  data
end

#get_jwks_with_http_info(opts = {}) ⇒ Array<(JWKS, Integer, Hash)>

JSON Web Key Set for id_token verification (RFC 7517). The set of public keys RPs use to verify Spatio-issued id_tokens. Cached for 5 minutes at the edge. Always includes the currently-active signing key plus any retired keys that may still be in circulation (id_token TTL is 1 hour + slack).

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(JWKS, Integer, Hash)>)

    JWKS data, response status code and response headers



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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
76
77
# File 'lib/spatio-sdk/api/o_auth_api.rb', line 35

def get_jwks_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: OAuthApi.get_jwks ...'
  end
  # resource path
  local_var_path = '/.well-known/jwks.json'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'JWKS'

  # auth_names
  auth_names = opts[:debug_auth_names] || []

  new_options = opts.merge(
    :operation => :"OAuthApi.get_jwks",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: OAuthApi#get_jwks\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_o_auth_discovery(opts = {}) ⇒ DiscoveryDocument

OAuth 2.1 authorization server metadata (RFC 8414). Returns the canonical metadata for the Spatio OAuth 2.1 + OpenID Connect server. Third-party RPs use this to auto-discover endpoint URLs, supported scopes, and signing algorithms. Identical payload to ‘/.well-known/openid-configuration` — either path is acceptable; OIDC clients prefer the openid-configuration alias.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



83
84
85
86
# File 'lib/spatio-sdk/api/o_auth_api.rb', line 83

def get_o_auth_discovery(opts = {})
  data, _status_code, _headers = get_o_auth_discovery_with_http_info(opts)
  data
end

#get_o_auth_discovery_with_http_info(opts = {}) ⇒ Array<(DiscoveryDocument, Integer, Hash)>

OAuth 2.1 authorization server metadata (RFC 8414). Returns the canonical metadata for the Spatio OAuth 2.1 + OpenID Connect server. Third-party RPs use this to auto-discover endpoint URLs, supported scopes, and signing algorithms. Identical payload to &#x60;/.well-known/openid-configuration&#x60; — either path is acceptable; OIDC clients prefer the openid-configuration alias.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(DiscoveryDocument, Integer, Hash)>)

    DiscoveryDocument data, response status code and response headers



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/spatio-sdk/api/o_auth_api.rb', line 92

def get_o_auth_discovery_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: OAuthApi.get_o_auth_discovery ...'
  end
  # resource path
  local_var_path = '/.well-known/oauth-authorization-server'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'DiscoveryDocument'

  # auth_names
  auth_names = opts[:debug_auth_names] || []

  new_options = opts.merge(
    :operation => :"OAuthApi.get_o_auth_discovery",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: OAuthApi#get_o_auth_discovery\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_open_id_configuration(opts = {}) ⇒ DiscoveryDocument

OpenID Connect Discovery 1.0 metadata. Alias of ‘/.well-known/oauth-authorization-server`. Provided so OIDC client libraries (NextAuth, Auth.js, oidc-client-ts, passport-openidconnect) auto-detect Spatio as an OIDC provider via their `wellKnown` / `discoveryUrl` config field.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



140
141
142
143
# File 'lib/spatio-sdk/api/o_auth_api.rb', line 140

def get_open_id_configuration(opts = {})
  data, _status_code, _headers = get_open_id_configuration_with_http_info(opts)
  data
end

#get_open_id_configuration_with_http_info(opts = {}) ⇒ Array<(DiscoveryDocument, Integer, Hash)>

OpenID Connect Discovery 1.0 metadata. Alias of &#x60;/.well-known/oauth-authorization-server&#x60;. Provided so OIDC client libraries (NextAuth, Auth.js, oidc-client-ts, passport-openidconnect) auto-detect Spatio as an OIDC provider via their &#x60;wellKnown&#x60; / &#x60;discoveryUrl&#x60; config field.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(DiscoveryDocument, Integer, Hash)>)

    DiscoveryDocument data, response status code and response headers



149
150
151
152
153
154
155
156
157
158
159
160
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
187
188
189
190
191
# File 'lib/spatio-sdk/api/o_auth_api.rb', line 149

def get_open_id_configuration_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: OAuthApi.get_open_id_configuration ...'
  end
  # resource path
  local_var_path = '/.well-known/openid-configuration'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'DiscoveryDocument'

  # auth_names
  auth_names = opts[:debug_auth_names] || []

  new_options = opts.merge(
    :operation => :"OAuthApi.get_open_id_configuration",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: OAuthApi#get_open_id_configuration\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_user_info(opts = {}) ⇒ UserInfoResponse

OIDC UserInfo (OpenID Connect Core 1.0 §5.3). Returns user claims gated by the scopes on the presenting access token. ‘sub` is always returned; `email`, `name`, etc. require their respective scopes.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



197
198
199
200
# File 'lib/spatio-sdk/api/o_auth_api.rb', line 197

def (opts = {})
  data, _status_code, _headers = (opts)
  data
end

#get_user_info_with_http_info(opts = {}) ⇒ Array<(UserInfoResponse, Integer, Hash)>

OIDC UserInfo (OpenID Connect Core 1.0 §5.3). Returns user claims gated by the scopes on the presenting access token. &#x60;sub&#x60; is always returned; &#x60;email&#x60;, &#x60;name&#x60;, etc. require their respective scopes.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(UserInfoResponse, Integer, Hash)>)

    UserInfoResponse data, response status code and response headers



206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
# File 'lib/spatio-sdk/api/o_auth_api.rb', line 206

def (opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: OAuthApi.get_user_info ...'
  end
  # resource path
  local_var_path = '/oauth2/userinfo'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'UserInfoResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"OAuthApi.get_user_info",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: OAuthApi#get_user_info\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#oauth_authorize(client_id, redirect_uri, response_type, code_challenge, code_challenge_method, opts = {}) ⇒ nil

OAuth 2.1 authorization endpoint (RFC 6749 + 7636 PKCE). Browser-redirect endpoint. Validates the client + redirect_uri, packs the request into a signed JWT, and 302s the user’s browser to the consent UI. The consent UI then POSTs to ‘/oauth2/authorize/confirm` with the user’s decision. OIDC additions: ‘scope=openid+profile+email`, `nonce`, `prompt` (none|login|consent), `max_age`.

Parameters:

  • client_id (String)
  • redirect_uri (String)
  • response_type (String)
  • code_challenge (String)
  • code_challenge_method (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :scope (String)
  • :state (String)
  • :nonce (String)
  • :prompt (String)
  • :max_age (Integer)

Returns:

  • (nil)


264
265
266
267
# File 'lib/spatio-sdk/api/o_auth_api.rb', line 264

def oauth_authorize(client_id, redirect_uri, response_type, code_challenge, code_challenge_method, opts = {})
  oauth_authorize_with_http_info(client_id, redirect_uri, response_type, code_challenge, code_challenge_method, opts)
  nil
end

#oauth_authorize_with_http_info(client_id, redirect_uri, response_type, code_challenge, code_challenge_method, opts = {}) ⇒ Array<(nil, Integer, Hash)>

OAuth 2.1 authorization endpoint (RFC 6749 + 7636 PKCE). Browser-redirect endpoint. Validates the client + redirect_uri, packs the request into a signed JWT, and 302s the user&#39;s browser to the consent UI. The consent UI then POSTs to &#x60;/oauth2/authorize/confirm&#x60; with the user&#39;s decision. OIDC additions: &#x60;scope&#x3D;openid+profile+email&#x60;, &#x60;nonce&#x60;, &#x60;prompt&#x60; (none|login|consent), &#x60;max_age&#x60;.

Parameters:

  • client_id (String)
  • redirect_uri (String)
  • response_type (String)
  • code_challenge (String)
  • code_challenge_method (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :scope (String)
  • :state (String)
  • :nonce (String)
  • :prompt (String)
  • :max_age (Integer)

Returns:

  • (Array<(nil, Integer, Hash)>)

    nil, response status code and response headers



283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
# File 'lib/spatio-sdk/api/o_auth_api.rb', line 283

def oauth_authorize_with_http_info(client_id, redirect_uri, response_type, code_challenge, code_challenge_method, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: OAuthApi.oauth_authorize ...'
  end
  # verify the required parameter 'client_id' is set
  if @api_client.config.client_side_validation && client_id.nil?
    fail ArgumentError, "Missing the required parameter 'client_id' when calling OAuthApi.oauth_authorize"
  end
  # verify the required parameter 'redirect_uri' is set
  if @api_client.config.client_side_validation && redirect_uri.nil?
    fail ArgumentError, "Missing the required parameter 'redirect_uri' when calling OAuthApi.oauth_authorize"
  end
  # verify the required parameter 'response_type' is set
  if @api_client.config.client_side_validation && response_type.nil?
    fail ArgumentError, "Missing the required parameter 'response_type' when calling OAuthApi.oauth_authorize"
  end
  # verify enum value
  allowable_values = ["code"]
  if @api_client.config.client_side_validation && !allowable_values.include?(response_type)
    fail ArgumentError, "invalid value for \"response_type\", must be one of #{allowable_values}"
  end
  # verify the required parameter 'code_challenge' is set
  if @api_client.config.client_side_validation && code_challenge.nil?
    fail ArgumentError, "Missing the required parameter 'code_challenge' when calling OAuthApi.oauth_authorize"
  end
  # verify the required parameter 'code_challenge_method' is set
  if @api_client.config.client_side_validation && code_challenge_method.nil?
    fail ArgumentError, "Missing the required parameter 'code_challenge_method' when calling OAuthApi.oauth_authorize"
  end
  # verify enum value
  allowable_values = ["S256"]
  if @api_client.config.client_side_validation && !allowable_values.include?(code_challenge_method)
    fail ArgumentError, "invalid value for \"code_challenge_method\", must be one of #{allowable_values}"
  end
  allowable_values = ["none", "login", "consent"]
  if @api_client.config.client_side_validation && opts[:'prompt'] && !allowable_values.include?(opts[:'prompt'])
    fail ArgumentError, "invalid value for \"prompt\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/oauth2/authorize'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'client_id'] = client_id
  query_params[:'redirect_uri'] = redirect_uri
  query_params[:'response_type'] = response_type
  query_params[:'code_challenge'] = code_challenge
  query_params[:'code_challenge_method'] = code_challenge_method
  query_params[:'scope'] = opts[:'scope'] if !opts[:'scope'].nil?
  query_params[:'state'] = opts[:'state'] if !opts[:'state'].nil?
  query_params[:'nonce'] = opts[:'nonce'] if !opts[:'nonce'].nil?
  query_params[:'prompt'] = opts[:'prompt'] if !opts[:'prompt'].nil?
  query_params[:'max_age'] = opts[:'max_age'] if !opts[:'max_age'].nil?

  # header parameters
  header_params = opts[:header_params] || {}

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type]

  # auth_names
  auth_names = opts[:debug_auth_names] || []

  new_options = opts.merge(
    :operation => :"OAuthApi.oauth_authorize",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: OAuthApi#oauth_authorize\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#oauth_introspect(token, opts = {}) ⇒ IntrospectionResponse

RFC 7662 token introspection. Accepts both OAuth access tokens and PATs.

Parameters:

  • token (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



373
374
375
376
# File 'lib/spatio-sdk/api/o_auth_api.rb', line 373

def oauth_introspect(token, opts = {})
  data, _status_code, _headers = oauth_introspect_with_http_info(token, opts)
  data
end

#oauth_introspect_with_http_info(token, opts = {}) ⇒ Array<(IntrospectionResponse, Integer, Hash)>

RFC 7662 token introspection. Accepts both OAuth access tokens and PATs.

Parameters:

  • token (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(IntrospectionResponse, Integer, Hash)>)

    IntrospectionResponse data, response status code and response headers



382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
# File 'lib/spatio-sdk/api/o_auth_api.rb', line 382

def oauth_introspect_with_http_info(token, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: OAuthApi.oauth_introspect ...'
  end
  # verify the required parameter 'token' is set
  if @api_client.config.client_side_validation && token.nil?
    fail ArgumentError, "Missing the required parameter 'token' when calling OAuthApi.oauth_introspect"
  end
  # resource path
  local_var_path = '/oauth2/introspect'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}
  form_params['token'] = token

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'IntrospectionResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || []

  new_options = opts.merge(
    :operation => :"OAuthApi.oauth_introspect",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: OAuthApi#oauth_introspect\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#oauth_revoke(token, opts = {}) ⇒ nil

RFC 7009 token revocation. Idempotent.

Parameters:

  • token (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (nil)


440
441
442
443
# File 'lib/spatio-sdk/api/o_auth_api.rb', line 440

def oauth_revoke(token, opts = {})
  oauth_revoke_with_http_info(token, opts)
  nil
end

#oauth_revoke_with_http_info(token, opts = {}) ⇒ Array<(nil, Integer, Hash)>

RFC 7009 token revocation. Idempotent.

Parameters:

  • token (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(nil, Integer, Hash)>)

    nil, response status code and response headers



449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
# File 'lib/spatio-sdk/api/o_auth_api.rb', line 449

def oauth_revoke_with_http_info(token, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: OAuthApi.oauth_revoke ...'
  end
  # verify the required parameter 'token' is set
  if @api_client.config.client_side_validation && token.nil?
    fail ArgumentError, "Missing the required parameter 'token' when calling OAuthApi.oauth_revoke"
  end
  # resource path
  local_var_path = '/oauth2/revoke'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}
  form_params['token'] = token

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type]

  # auth_names
  auth_names = opts[:debug_auth_names] || []

  new_options = opts.merge(
    :operation => :"OAuthApi.oauth_revoke",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: OAuthApi#oauth_revoke\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#oauth_token(grant_type, opts = {}) ⇒ TokenResponse

Exchange authorization code or refresh token for an access token (+ id_token if ‘openid` scope).

Parameters:

  • grant_type (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :code (String)

    Required for authorization_code grant.

  • :code_verifier (String)

    PKCE verifier — required for authorization_code grant.

  • :redirect_uri (String)
  • :refresh_token (String)

    Required for refresh_token grant.

  • :client_id (String)
  • :client_secret (String)

Returns:



511
512
513
514
# File 'lib/spatio-sdk/api/o_auth_api.rb', line 511

def oauth_token(grant_type, opts = {})
  data, _status_code, _headers = oauth_token_with_http_info(grant_type, opts)
  data
end

#oauth_token_with_http_info(grant_type, opts = {}) ⇒ Array<(TokenResponse, Integer, Hash)>

Exchange authorization code or refresh token for an access token (+ id_token if &#x60;openid&#x60; scope).

Parameters:

  • grant_type (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :code (String)

    Required for authorization_code grant.

  • :code_verifier (String)

    PKCE verifier — required for authorization_code grant.

  • :redirect_uri (String)
  • :refresh_token (String)

    Required for refresh_token grant.

  • :client_id (String)
  • :client_secret (String)

Returns:

  • (Array<(TokenResponse, Integer, Hash)>)

    TokenResponse data, response status code and response headers



526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
# File 'lib/spatio-sdk/api/o_auth_api.rb', line 526

def oauth_token_with_http_info(grant_type, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: OAuthApi.oauth_token ...'
  end
  # verify the required parameter 'grant_type' is set
  if @api_client.config.client_side_validation && grant_type.nil?
    fail ArgumentError, "Missing the required parameter 'grant_type' when calling OAuthApi.oauth_token"
  end
  # verify enum value
  allowable_values = ["authorization_code", "refresh_token"]
  if @api_client.config.client_side_validation && !allowable_values.include?(grant_type)
    fail ArgumentError, "invalid value for \"grant_type\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/oauth2/token'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}
  form_params['grant_type'] = grant_type
  form_params['code'] = opts[:'code'] if !opts[:'code'].nil?
  form_params['code_verifier'] = opts[:'code_verifier'] if !opts[:'code_verifier'].nil?
  form_params['redirect_uri'] = opts[:'redirect_uri'] if !opts[:'redirect_uri'].nil?
  form_params['refresh_token'] = opts[:'refresh_token'] if !opts[:'refresh_token'].nil?
  form_params['client_id'] = opts[:'client_id'] if !opts[:'client_id'].nil?
  form_params['client_secret'] = opts[:'client_secret'] if !opts[:'client_secret'].nil?

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'TokenResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || []

  new_options = opts.merge(
    :operation => :"OAuthApi.oauth_token",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: OAuthApi#oauth_token\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#post_user_info(opts = {}) ⇒ UserInfoResponse

Same as GET /oauth2/userinfo. Provided for clients that send the bearer in the body.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



594
595
596
597
# File 'lib/spatio-sdk/api/o_auth_api.rb', line 594

def (opts = {})
  data, _status_code, _headers = (opts)
  data
end

#post_user_info_with_http_info(opts = {}) ⇒ Array<(UserInfoResponse, Integer, Hash)>

Same as GET /oauth2/userinfo. Provided for clients that send the bearer in the body.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(UserInfoResponse, Integer, Hash)>)

    UserInfoResponse data, response status code and response headers



602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
# File 'lib/spatio-sdk/api/o_auth_api.rb', line 602

def (opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: OAuthApi.post_user_info ...'
  end
  # resource path
  local_var_path = '/oauth2/userinfo'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'UserInfoResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"OAuthApi.post_user_info",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: OAuthApi#post_user_info\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#register_o_auth_client(client_registration_request, opts = {}) ⇒ ClientRegistrationResponse

Register a new OAuth 2.1 client (RFC 7591 dynamic client registration). Returns a fresh ‘client_id` (and, for confidential clients, `client_secret`) plus a one-time `registration_access_token` the client can use later to update its registration. Public clients (mobile, SPA) MUST use `token_endpoint_auth_method: none` and PKCE. Rate-limited to 10 registrations per hour per source IP.

Parameters:

Returns:



651
652
653
654
# File 'lib/spatio-sdk/api/o_auth_api.rb', line 651

def register_o_auth_client(client_registration_request, opts = {})
  data, _status_code, _headers = register_o_auth_client_with_http_info(client_registration_request, opts)
  data
end

#register_o_auth_client_with_http_info(client_registration_request, opts = {}) ⇒ Array<(ClientRegistrationResponse, Integer, Hash)>

Register a new OAuth 2.1 client (RFC 7591 dynamic client registration). Returns a fresh &#x60;client_id&#x60; (and, for confidential clients, &#x60;client_secret&#x60;) plus a one-time &#x60;registration_access_token&#x60; the client can use later to update its registration. Public clients (mobile, SPA) MUST use &#x60;token_endpoint_auth_method: none&#x60; and PKCE. Rate-limited to 10 registrations per hour per source IP.

Parameters:

Returns:

  • (Array<(ClientRegistrationResponse, Integer, Hash)>)

    ClientRegistrationResponse data, response status code and response headers



661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
# File 'lib/spatio-sdk/api/o_auth_api.rb', line 661

def register_o_auth_client_with_http_info(client_registration_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: OAuthApi.register_o_auth_client ...'
  end
  # verify the required parameter 'client_registration_request' is set
  if @api_client.config.client_side_validation && client_registration_request.nil?
    fail ArgumentError, "Missing the required parameter 'client_registration_request' when calling OAuthApi.register_o_auth_client"
  end
  # resource path
  local_var_path = '/oauth2/register'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(client_registration_request)

  # return_type
  return_type = opts[:debug_return_type] || 'ClientRegistrationResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || []

  new_options = opts.merge(
    :operation => :"OAuthApi.register_o_auth_client",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: OAuthApi#register_o_auth_client\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end