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.
164 165 166 |
# File 'lib/stytch/m2m.rb', line 164 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_id` must be unique within your project. The type of this field is nilable
String
. - 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_secret` must be at least 8 characters long and pass entropy requirements. The type of this field is nilable
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
. - trusted_metadata
-
The ‘trusted_metadata` field contains an arbitrary JSON object of application-specific data. See the [Metadata](stytch.com/docs/api/metadata) reference for complete field behavior details. The type of this field is nilable
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_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
.
363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 |
# File 'lib/stytch/m2m.rb', line 363 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 a 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 when[authenticating the token](stytch.com/docs/b2b/api/authenticate-m2m-token)[authenticating the token](stytch.com/docs/api/authenticate-m2m-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
.
321 322 323 324 325 326 |
# File 'lib/stytch/m2m.rb', line 321 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
.
190 191 192 193 194 195 196 197 |
# File 'lib/stytch/m2m.rb', line 190 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 request
-
‘client_name`: Search for clients by exact match on client name
-
‘scopes`: Search for clients assigned a specific scope
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
. - query
-
The optional query object contains the operator, i.e. ‘AND` or `OR`, 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 nilable
M2MSearchQuery
(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_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
.
231 232 233 234 235 236 237 238 239 240 241 242 243 |
# File 'lib/stytch/m2m.rb', line 231 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 a 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 a 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 when[authenticating the token](stytch.com/docs/b2b/api/authenticate-m2m-token)[authenticating the token](stytch.com/docs/api/authenticate-m2m-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 ‘active` or `inactive`. The type of this field is nilable
UpdateRequestStatus
(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_metadata` field contains an arbitrary JSON object of application-specific data. See the [Metadata](stytch.com/docs/api/metadata) reference for complete field behavior details. The type of this field is nilable
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_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
.
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 |
# File 'lib/stytch/m2m.rb', line 281 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 |