Skip to content

Latest commit

 

History

History
286 lines (198 loc) · 16.8 KB

File metadata and controls

286 lines (198 loc) · 16.8 KB

TokenManagement

Overview

Available Operations

reissue_id_token

The API is expected to be called only when the value of the action parameter in a response from the /auth/token API is ID_TOKEN_REISSUABLE. The purpose of the /idtoken/reissue API is to generate a token response that includes a new ID token together with a new access token and a refresh token.

Example Usage

require 'authlete_ruby_sdk'

Models = ::Authlete::Models
s = ::Authlete::Client.new(
  bearer: '<YOUR_BEARER_TOKEN_HERE>'
)
res = s.token_management.reissue_id_token(service_id: '<id>')

unless res.idtoken_reissue_response.nil?
  # handle response
end

Parameters

Parameter Type Required Description
service_id ::String ✔️ A service ID.
idtoken_reissue_request T.nilable(Models::Components::IdtokenReissueRequest) N/A

Response

T.nilable(Models::Operations::IdtokenReissueApiResponse)

Errors

Error Type Status Code Content Type
Models::Errors::ResultError 400, 401, 403 application/json
Models::Errors::ResultError 500 application/json
Errors::APIError 4XX, 5XX */*

list

Get the list of access tokens that are associated with the service.

Example Usage

require 'authlete_ruby_sdk'

Models = ::Authlete::Models
s = ::Authlete::Client.new(
  bearer: '<YOUR_BEARER_TOKEN_HERE>'
)

req = Models::Operations::AuthTokenGetListApiRequest.new(
  service_id: '<id>'
)
res = s.token_management.list(request: req)

unless res.token_get_list_response.nil?
  # handle response
end

Parameters

Parameter Type Required Description
request Models::Operations::AuthTokenGetListApiRequest ✔️ The request object to use for the request.

Response

T.nilable(Models::Operations::AuthTokenGetListApiResponse)

Errors

Error Type Status Code Content Type
Models::Errors::ResultError 400, 401, 403 application/json
Models::Errors::ResultError 500 application/json
Errors::APIError 4XX, 5XX */*

create

Create an access token.

Example Usage

require 'authlete_ruby_sdk'

Models = ::Authlete::Models
s = ::Authlete::Client.new(
  bearer: '<YOUR_BEARER_TOKEN_HERE>'
)
res = s.token_management.create(service_id: '<id>', token_create_request: Models::Components::TokenCreateRequest.new(
  grant_type: Models::Components::GrantType::AUTHORIZATION_CODE,
  client_id: 26_888_344_961_664,
  subject: 'john',
  scopes: [
    'history.read',
    'timeline.read',
  ]
))

unless res.token_create_response.nil?
  # handle response
end

Parameters

Parameter Type Required Description
service_id ::String ✔️ A service ID.
token_create_request Models::Components::TokenCreateRequest ✔️ N/A

Response

T.nilable(Models::Operations::AuthTokenCreateApiResponse)

Errors

Error Type Status Code Content Type
Models::Errors::ResultError 400, 401, 403 application/json
Models::Errors::ResultError 500 application/json
Errors::APIError 4XX, 5XX */*

update

Update an access token.

Example Usage

require 'authlete_ruby_sdk'

Models = ::Authlete::Models
s = ::Authlete::Client.new(
  bearer: '<YOUR_BEARER_TOKEN_HERE>'
)
res = s.token_management.update(service_id: '<id>', token_update_request: Models::Components::TokenUpdateRequest.new(
  access_token: 'Z5a40U6dWvw2gMoCOAFbZcM85q4HC0Z--0YKD9-Nf6Q',
  scopes: [
    'history.read',
  ]
))

unless res.token_update_response.nil?
  # handle response
end

Parameters

Parameter Type Required Description
service_id ::String ✔️ A service ID.
token_update_request Models::Components::TokenUpdateRequest ✔️ N/A

Response

T.nilable(Models::Operations::AuthTokenUpdateApiResponse)

Errors

Error Type Status Code Content Type
Models::Errors::ResultError 400, 401, 403 application/json
Models::Errors::ResultError 500 application/json
Errors::APIError 4XX, 5XX */*

destroy

Delete an access token.

Example Usage

require 'authlete_ruby_sdk'

Models = ::Authlete::Models
s = ::Authlete::Client.new(
  bearer: '<YOUR_BEARER_TOKEN_HERE>'
)
res = s.token_management.destroy(service_id: '<id>', access_token_identifier: '<value>')

if res.status_code == 200
  # handle response
end

Parameters

Parameter Type Required Description
service_id ::String ✔️ A service ID.
access_token_identifier ::String ✔️ The identifier of an existing access token. The identifier is the value of the access token
or the value of the hash of the access token.

Response

T.nilable(Models::Operations::AuthTokenDeleteApiResponse)

Errors

Error Type Status Code Content Type
Models::Errors::ResultError 400, 401, 403 application/json
Models::Errors::ResultError 500 application/json
Errors::APIError 4XX, 5XX */*

revoke

Revoke an access token.

Example Usage

require 'authlete_ruby_sdk'

Models = ::Authlete::Models
s = ::Authlete::Client.new(
  bearer: '<YOUR_BEARER_TOKEN_HERE>'
)
res = s.token_management.revoke(service_id: '<id>', token_revoke_request: Models::Components::TokenRevokeRequest.new(
  access_token_identifier: 'Z5a40U6dWvw2gMoCOAFbZcM85q4HC0Z--0YKD9-Nf6Q'
))

unless res.token_revoke_response.nil?
  # handle response
end

Parameters

Parameter Type Required Description
service_id ::String ✔️ A service ID.
token_revoke_request Models::Components::TokenRevokeRequest ✔️ N/A

Response

T.nilable(Models::Operations::AuthTokenRevokeApiResponse)

Errors

Error Type Status Code Content Type
Models::Errors::ResultError 400, 401, 403, 404 application/json
Models::Errors::ResultError 500 application/json
Errors::APIError 4XX, 5XX */*