Class: Stytch::M2M::Clients
- Inherits:
-
Object
- Object
- Stytch::M2M::Clients
- Includes:
- RequestHelper
- Defined in:
- lib/stytch/m2m.rb
Overview
ENDMANUAL(M2M::authenticate_token)
Defined Under Namespace
Classes: Secrets
Instance Attribute Summary collapse
-
#secrets ⇒ Object
readonly
Returns the value of attribute secrets.
Instance Method Summary collapse
-
#create(scopes:, client_id: nil, client_secret: nil, client_name: nil, client_description: nil, trusted_metadata: nil) ⇒ Object
Creates a new M2M Client.
-
#delete(client_id:) ⇒ Object
Deletes the M2M Client.
-
#get(client_id:) ⇒ Object
Gets information about an existing M2M Client.
-
#initialize(connection) ⇒ Clients
constructor
A new instance of Clients.
-
#search(cursor: nil, limit: nil, query: nil) ⇒ Object
Search for M2M Clients within your Stytch Project.
-
#update(client_id:, client_name: nil, client_description: nil, status: nil, scopes: nil, trusted_metadata: nil) ⇒ Object
Updates an existing M2M Client.
Methods included from RequestHelper
#delete_request, #get_request, #post_request, #put_request, #request_with_query_params
Constructor Details
Instance Attribute Details
#secrets ⇒ Object (readonly)
Returns the value of attribute secrets.
211 212 213 |
# File 'lib/stytch/m2m.rb', line 211 def secrets @secrets end |
Instance Method Details
#create(scopes:, client_id: nil, client_secret: nil, client_name: nil, client_description: nil, trusted_metadata: nil) ⇒ Object
Creates a new M2M Client. On initial client creation, you may pass in a custom client_id or client_secret to import an existing M2M client. If you do not pass in a custom client_id or client_secret, one will be generated automatically. The client_id must be unique among all clients in your project.
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:
- scopes
An array of scopes assigned to the client. The type of this field is list of
String.- client_id
If provided, the ID of the client to create. If not provided, Stytch will generate this value for you. The
client_idmust be unique within your project. The type of this field is nilableString.- client_secret
If provided, the stored secret of the client to create. If not provided, Stytch will generate this value for you. If provided, the
client_secretmust be at least 8 characters long and pass entropy requirements. The type of this field is nilableString.- 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.- trusted_metadata
The
trusted_metadatafield contains an arbitrary JSON object of application-specific data. See the Metadata reference for complete field behavior details. The type of this field is nilableobject.
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.- m2m_client
The M2M Client created by this API call. The type of this field is
M2MClientWithClientSecret(+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.
410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 |
# File 'lib/stytch/m2m.rb', line 410 def create( scopes:, client_id: nil, client_secret: nil, client_name: nil, client_description: nil, trusted_metadata: nil ) headers = {} request = { scopes: scopes } request[:client_id] = client_id unless client_id.nil? request[:client_secret] = client_secret unless client_secret.nil? request[:client_name] = client_name unless client_name.nil? request[:client_description] = client_description unless client_description.nil? request[:trusted_metadata] = unless .nil? post_request('/v1/m2m/clients', request, headers) end |
#delete(client_id:) ⇒ Object
Deletes the M2M Client.
Important: Deleting an M2M Client will not invalidate any existing JWTs issued to the client, only prevent it from receiving new ones.
To protect more-sensitive routes, pass a lower max_token_age value whenauthenticating the tokenauthenticating the token.
Parameters:
- client_id
The ID of the 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.- client_id
The ID of the client. The type of this field is
String.- 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.
368 369 370 371 372 373 |
# File 'lib/stytch/m2m.rb', line 368 def delete( client_id: ) headers = {} delete_request("/v1/m2m/clients/#{client_id}", headers) end |
#get(client_id:) ⇒ Object
Gets information about an existing M2M Client.
Parameters:
- client_id
The ID of the 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.- m2m_client
The M2M Client affected by this operation. The type of this field is
M2MClient(+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.
237 238 239 240 241 242 243 244 |
# File 'lib/stytch/m2m.rb', line 237 def get( client_id: ) headers = {} query_params = {} request = request_with_query_params("/v1/m2m/clients/#{client_id}", query_params) get_request(request, headers) end |
#search(cursor: nil, limit: nil, query: nil) ⇒ Object
Search for M2M Clients within your Stytch Project. Submit an empty query in the request to return all M2M Clients.
The following search filters are supported today:
client_id: Pass in a list of client IDs to get many clients in a single requestclient_name: Search for clients by exact match on client namescopes: Search for clients assigned a specific scope
Parameters:
- cursor
The
cursorfield 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 thecursor. If you receive a response that includes a non-nullnext_cursorin theresults_metadataobject, repeat the search call with thenext_cursorvalue set to thecursorfield to retrieve the next page of results. Continue to make search calls until thenext_cursorin the response is null. The type of this field is nilableString.- 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
cursorfield. The type of this field is nilableInteger.- query
The optional query object contains the operator, i.e.
ANDorOR, and the operands that will filter your results. Only an operator is required. If you include no operands, no filtering will be applied. If you include no query object, it will return all results with no filtering applied. The type of this field is nilableM2MSearchQuery(+object+).
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.- m2m_clients
An array of M2M Clients that match your search query. The type of this field is list of
M2MClient(+object+).- results_metadata
The search
results_metadataobject contains metadata relevant to your specific query like total andnext_cursor. The type of this field isResultsMetadata(+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.
278 279 280 281 282 283 284 285 286 287 288 289 290 |
# File 'lib/stytch/m2m.rb', line 278 def search( cursor: nil, limit: nil, query: nil ) headers = {} request = {} request[:cursor] = cursor unless cursor.nil? request[:limit] = limit unless limit.nil? request[:query] = query unless query.nil? post_request('/v1/m2m/clients/search', request, headers) end |
#update(client_id:, client_name: nil, client_description: nil, status: nil, scopes: nil, trusted_metadata: nil) ⇒ Object
Updates an existing M2M Client. You can use this endpoint to activate or deactivate an M2M Client by changing its status. A deactivated M2M Client will not be allowed to perform future token exchange flows until it is reactivated.
Important: Deactivating an M2M Client will not invalidate any existing JWTs issued to the client, only prevent it from receiving new ones.
To protect more-sensitive routes, pass a lower max_token_age value whenauthenticating the tokenauthenticating the token.
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.- status
The status of the client - either
activeorinactive. The type of this field is nilableUpdateRequestStatus(string enum).- scopes
An array of scopes assigned to the client. The type of this field is nilable list of
String.- trusted_metadata
The
trusted_metadatafield contains an arbitrary JSON object of application-specific data. See the Metadata reference for complete field behavior details. The type of this field is nilableobject.
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.- m2m_client
The M2M Client affected by this operation. The type of this field is
M2MClient(+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.
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 |
# File 'lib/stytch/m2m.rb', line 328 def update( client_id:, client_name: nil, client_description: nil, status: nil, scopes: nil, trusted_metadata: nil ) headers = {} request = {} request[:client_name] = client_name unless client_name.nil? request[:client_description] = client_description unless client_description.nil? request[:status] = status unless status.nil? request[:scopes] = scopes unless scopes.nil? request[:trusted_metadata] = unless .nil? put_request("/v1/m2m/clients/#{client_id}", request, headers) end |