Class: Stytch::ConnectedApp::Clients

Inherits:
Object
  • Object
show all
Includes:
RequestHelper
Defined in:
lib/stytch/connected_apps.rb

Defined Under Namespace

Classes: Secrets

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from RequestHelper

#delete_request, #get_request, #post_request, #put_request, #request_with_query_params

Constructor Details

#initialize(connection) ⇒ Clients

Returns a new instance of Clients.



26
27
28
29
30
# File 'lib/stytch/connected_apps.rb', line 26

def initialize(connection)
  @connection = connection

  @secrets = Stytch::ConnectedApp::Clients::Secrets.new(@connection)
end

Instance Attribute Details

#secretsObject (readonly)

Returns the value of attribute secrets.



24
25
26
# File 'lib/stytch/connected_apps.rb', line 24

def secrets
  @secrets
end

Instance Method Details

#create(client_type:, client_name: nil, client_description: nil, redirect_urls: nil, full_access_allowed: nil, access_token_expiry_minutes: nil, access_token_custom_audience: nil, access_token_template_content: nil, post_logout_redirect_urls: nil, logo_url: nil, bypass_consent_for_offline_access: nil) ⇒ Object

Creates a new Connected App. If the Connected App ‘client_type` is `first_party` or `third_party` a `client_secret` is returned.

Important: This is the only time you will be able to view the generated ‘client_secret` in the API response. Stytch stores a hash of the `client_secret` and cannot recover the value if lost. Be sure to persist the `client_secret` in a secure location. If the `client_secret` is lost, you will need to trigger a secret rotation flow to receive another one.

Parameters:

client_type

The type of Connected App. Supported values are ‘first_party`, `first_party_public`, `third_party`, and `third_party_public`. The type of this field is CreateRequestClientType (string enum).

client_name

A human-readable name for the client. The type of this field is nilable String.

client_description

A human-readable description for the client. The type of this field is nilable String.

redirect_urls

Array of redirect URI values for use in OAuth Authorization flows. The type of this field is nilable list of String.

full_access_allowed

Valid for first party clients only. If ‘true`, an authorization token granted to this Client can be exchanged for a full Stytch session. The type of this field is nilable Boolean.

access_token_expiry_minutes

The number of minutes before the access token expires. The default is 60 minutes. The type of this field is nilable Integer.

access_token_custom_audience

The custom audience for the access token. The type of this field is nilable String.

access_token_template_content

The content of the access token custom claims template. The template must be a valid JSON object. The type of this field is nilable String.

post_logout_redirect_urls

Array of redirect URI values for use in OIDC Logout flows. The type of this field is nilable list of String.

logo_url

The logo URL of the Connected App, if any. The type of this field is nilable String.

bypass_consent_for_offline_access

Valid for first party clients only. If true, the client does not need to request explicit user consent for the ‘offline_access` scope. The type of this field is nilable Boolean.

Returns:

An object with the following fields:

request_id

Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we may ask for this value to help identify a specific API call when helping you debug an issue. The type of this field is String.

connected_app

The Connected App created by this API call. The type of this field is ConnectedAppWithClientSecret (object).

status_code

The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors. The type of this field is Integer.



247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
# File 'lib/stytch/connected_apps.rb', line 247

def create(
  client_type:,
  client_name: nil,
  client_description: nil,
  redirect_urls: nil,
  full_access_allowed: nil,
  access_token_expiry_minutes: nil,
  access_token_custom_audience: nil,
  access_token_template_content: nil,
  post_logout_redirect_urls: nil,
  logo_url: nil,
  bypass_consent_for_offline_access: nil
)
  headers = {}
  request = {
    client_type: client_type
  }
  request[:client_name] = client_name unless client_name.nil?
  request[:client_description] = client_description unless client_description.nil?
  request[:redirect_urls] = redirect_urls unless redirect_urls.nil?
  request[:full_access_allowed] = full_access_allowed unless full_access_allowed.nil?
  request[:access_token_expiry_minutes] = access_token_expiry_minutes unless access_token_expiry_minutes.nil?
  request[:access_token_custom_audience] = access_token_custom_audience unless access_token_custom_audience.nil?
  request[:access_token_template_content] = access_token_template_content unless access_token_template_content.nil?
  request[:post_logout_redirect_urls] = post_logout_redirect_urls unless post_logout_redirect_urls.nil?
  request[:logo_url] = logo_url unless logo_url.nil?
  request[:bypass_consent_for_offline_access] = bypass_consent_for_offline_access unless bypass_consent_for_offline_access.nil?

  post_request('/v1/connected_apps/clients', request, headers)
end

#delete(client_id:) ⇒ Object

Deletes a Connected App.

Parameters:

client_id

The ID of the client. The type of this field is String.

Returns:

An object with the following fields:

request_id

(no documentation yet) The type of this field is String.

client_id

The ID of the client. The type of this field is String.

status_code

(no documentation yet) The type of this field is Integer.



154
155
156
157
158
159
# File 'lib/stytch/connected_apps.rb', line 154

def delete(
  client_id:
)
  headers = {}
  delete_request("/v1/connected_apps/clients/#{client_id}", headers)
end

#get(client_id:) ⇒ Object

Retrieve details of a specific Connected App by ‘client_id`.

Parameters:

client_id

The ID of the Connected App client. The type of this field is String.

Returns:

An object with the following fields:

request_id

Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we may ask for this value to help identify a specific API call when helping you debug an issue. The type of this field is String.

connected_app

The Connected App affected by this operation. The type of this field is ConnectedApp (object).

status_code

The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors. The type of this field is Integer.



50
51
52
53
54
55
56
57
# File 'lib/stytch/connected_apps.rb', line 50

def get(
  client_id:
)
  headers = {}
  query_params = {}
  request = request_with_query_params("/v1/connected_apps/clients/#{client_id}", query_params)
  get_request(request, headers)
end

#search(cursor: nil, limit: nil) ⇒ Object

Search for Connected Apps. Supports cursor-based pagination. Specific filters coming soon.

Parameters:

cursor

The ‘cursor` field allows you to paginate through your results. Each result array is limited to 1000 results. If your query returns more than 1000 results, you will need to paginate the responses using the `cursor`. If you receive a response that includes a non-null `next_cursor` in the `results_metadata` object, repeat the search call with the `next_cursor` value set to the `cursor` field to retrieve the next page of results. Continue to make search calls until the `next_cursor` in the response is null. The type of this field is nilable String.

limit

The number of search results to return per page. The default limit is 100. A maximum of 1000 results can be returned by a single search request. If the total size of your result set is greater than one page size, you must paginate the response. See the ‘cursor` field. The type of this field is nilable Integer.

Returns:

An object with the following fields:

request_id

Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we may ask for this value to help identify a specific API call when helping you debug an issue. The type of this field is String.

connected_apps

(no documentation yet) The type of this field is list of ConnectedApp (object).

results_metadata

The search ‘results_metadata` object contains metadata relevant to your specific query like total and `next_cursor`. The type of this field is ResultsMetadata (object).

status_code

The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors. The type of this field is Integer.



185
186
187
188
189
190
191
192
193
194
195
# File 'lib/stytch/connected_apps.rb', line 185

def search(
  cursor: nil,
  limit: nil
)
  headers = {}
  request = {}
  request[:cursor] = cursor unless cursor.nil?
  request[:limit] = limit unless limit.nil?

  post_request('/v1/connected_apps/clients/search', request, headers)
end

#update(client_id:, client_name: nil, client_description: nil, redirect_urls: nil, full_access_allowed: nil, access_token_expiry_minutes: nil, access_token_custom_audience: nil, access_token_template_content: nil, post_logout_redirect_urls: nil, logo_url: nil, bypass_consent_for_offline_access: nil) ⇒ Object

Updates mutable fields of a Connected App. Cannot update Client Type, Client ID, or Secrets.

Parameters:

client_id

The ID of the client. The type of this field is String.

client_name

A human-readable name for the client. The type of this field is nilable String.

client_description

A human-readable description for the client. The type of this field is nilable String.

redirect_urls

Array of redirect URI values for use in OAuth Authorization flows. The type of this field is nilable list of String.

full_access_allowed

Valid for first party clients only. If ‘true`, an authorization token granted to this Client can be exchanged for a full Stytch session. The type of this field is nilable Boolean.

access_token_expiry_minutes

The number of minutes before the access token expires. The default is 60 minutes. The type of this field is nilable Integer.

access_token_custom_audience

The custom audience for the access token. The type of this field is nilable String.

access_token_template_content

The content of the access token custom claims template. The template must be a valid JSON object. The type of this field is nilable String.

post_logout_redirect_urls

Array of redirect URI values for use in OIDC Logout flows. The type of this field is nilable list of String.

logo_url

The logo URL of the Connected App, if any. The type of this field is nilable String.

bypass_consent_for_offline_access

Valid for first party clients only. If true, the client does not need to request explicit user consent for the ‘offline_access` scope. The type of this field is nilable Boolean.

Returns:

An object with the following fields:

request_id

Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we may ask for this value to help identify a specific API call when helping you debug an issue. The type of this field is String.

connected_app

The Connected App affected by this operation. The type of this field is ConnectedApp (object).

status_code

The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors. The type of this field is Integer.



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/stytch/connected_apps.rb', line 107

def update(
  client_id:,
  client_name: nil,
  client_description: nil,
  redirect_urls: nil,
  full_access_allowed: nil,
  access_token_expiry_minutes: nil,
  access_token_custom_audience: nil,
  access_token_template_content: nil,
  post_logout_redirect_urls: nil,
  logo_url: nil,
  bypass_consent_for_offline_access: nil
)
  headers = {}
  request = {}
  request[:client_name] = client_name unless client_name.nil?
  request[:client_description] = client_description unless client_description.nil?
  request[:redirect_urls] = redirect_urls unless redirect_urls.nil?
  request[:full_access_allowed] = full_access_allowed unless full_access_allowed.nil?
  request[:access_token_expiry_minutes] = access_token_expiry_minutes unless access_token_expiry_minutes.nil?
  request[:access_token_custom_audience] = access_token_custom_audience unless access_token_custom_audience.nil?
  request[:access_token_template_content] = access_token_template_content unless access_token_template_content.nil?
  request[:post_logout_redirect_urls] = post_logout_redirect_urls unless post_logout_redirect_urls.nil?
  request[:logo_url] = logo_url unless logo_url.nil?
  request[:bypass_consent_for_offline_access] = bypass_consent_for_offline_access unless bypass_consent_for_offline_access.nil?

  put_request("/v1/connected_apps/clients/#{client_id}", request, headers)
end