generateUserTokenWithHttpInfo method

Future<Response> generateUserTokenWithHttpInfo(
  1. String account,
  2. String user, {
  3. GenerateUserTokenRequest? generateUserTokenRequest,
})

Generate a user token

Generates a new user token resource. User tokens, by default, expire after 2 weeks. Though this can be adjusted via the expiry attribute. Typically, you'd want to generate a token using the tokens resource, using the user's email and password. But this endpoint can be used by admins to generate a token on a user's behalf. This endpoint is particularly useful for generating tokens for a user without a password, or if you want to manage logins another way, e.g. server-side.

Note: This method returns the HTTP Response.

Parameters:

  • String account (required): The identifier (UUID) or slug of your Keygen account.

  • String user (required): The identifier (UUID) or email of the user to generate a token for.

  • GenerateUserTokenRequest generateUserTokenRequest:

Implementation

Future<Response> generateUserTokenWithHttpInfo(String account, String user, { GenerateUserTokenRequest? generateUserTokenRequest, }) async {
  // ignore: prefer_const_declarations
  final path = r'/accounts/{account}/users/{user}/tokens'
    .replaceAll('{account}', account)
    .replaceAll('{user}', user);

  // ignore: prefer_final_locals
  Object? postBody = generateUserTokenRequest;

  final queryParams = <QueryParam>[];
  final headerParams = <String, String>{};
  final formParams = <String, String>{};

  const contentTypes = <String>['application/vnd.api+json'];


  return apiClient.invokeAPI(
    path,
    'POST',
    queryParams,
    postBody,
    headerParams,
    formParams,
    contentTypes.isEmpty ? null : contentTypes.first,
  );
}