Class: SafetyKit::Resources::AccessTokens

Inherits:
Object
  • Object
show all
Defined in:
lib/safety_kit/resources/access_tokens.rb,
sig/safety_kit/resources/access_tokens.rbs

Overview

Exchange a long-lived API key for a short-lived access token suitable for delegated or time-boxed use.

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ AccessTokens

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of AccessTokens.

Parameters:



43
44
45
# File 'lib/safety_kit/resources/access_tokens.rb', line 43

def initialize(client:)
  @client = client
end

Instance Method Details

#create_access_token(customer_session_id: nil, expires_in: nil, user_id: nil, request_options: {}) ⇒ SafetyKit::Models::AccessTokenCreateAccessTokenResponse

Some parameter documentations has been truncated, see Models::AccessTokenCreateAccessTokenParams for more details.

Exchange a long-lived API key for a short-lived access token. Authenticate with your long-lived API key as the Bearer token; the response contains a new token that authenticates the same team until it expires. Short-lived access tokens cannot be used to create additional access tokens.

Parameters:

  • customer_session_id (String)

    Optional opaque session identifier to associate with the access token.

  • expires_in (Integer)

    Lifetime of the access token in seconds. Defaults to 3600 (1 hour). Minimum 300

  • user_id (String)

    Optional user identifier to associate with the access token for attribution. Use

  • request_options (SafetyKit::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



29
30
31
32
33
34
35
36
37
38
# File 'lib/safety_kit/resources/access_tokens.rb', line 29

def create_access_token(params = {})
  parsed, options = SafetyKit::AccessTokenCreateAccessTokenParams.dump_request(params)
  @client.request(
    method: :post,
    path: "v1/access_tokens",
    body: parsed,
    model: SafetyKit::Models::AccessTokenCreateAccessTokenResponse,
    options: options
  )
end