Module: WorkOS::Widgets

Extended by:
Client
Defined in:
lib/workos/widgets.rb

Overview

The Widgets module provides resource methods for working with the Widgets APIs

Constant Summary collapse

WIDGET_SCOPES =
WorkOS::Types::WidgetScope::ALL

Class Method Summary collapse

Methods included from Client

client, delete_request, execute_request, get_request, handle_error_response, post_request, put_request, user_agent

Class Method Details

.get_token(organization_id:, user_id:, scopes:) ⇒ Object

Generate a widget token.

Parameters:

  • organization_id (String)

    The ID of the organization to generate the token for.

  • user_id (String)

    The ID of the user to generate the token for.

  • The (WidgetScope[])

    scopes to generate the token for.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/workos/widgets.rb', line 18

def get_token(organization_id:, user_id:, scopes:)
  validate_scopes(scopes)

  request = post_request(
    auth: true,
    body: {
      organization_id: organization_id,
      user_id: user_id,
      scopes: scopes,
    },
    path: '/widgets/token',
  )

  response = execute_request(request: request)

  JSON.parse(response.body)['token']
end