generateAccessToken method

Future<GenerateAccessTokenResponse> generateAccessToken(
  1. String environment, {
  2. String? expireTime,
  3. String? ttl,
  4. String? $fields,
})

Generates an access token for the user's environment.

Request parameters:

environment - Required. The environment to generate the access token for. Value must have pattern ^users/\[^/\]+/environments/\[^/\]+$.

expireTime - Desired expiration time of the access token. This value must be at most 24 hours in the future. If a value is not specified, the token's expiration time will be set to a default value of 1 hour in the future.

ttl - Desired lifetime duration of the access token. This value must be at most 24 hours. If a value is not specified, the token's lifetime will be set to a default value of 1 hour.

$fields - Selector specifying which fields to include in a partial response.

Completes with a GenerateAccessTokenResponse.

Completes with a commons.ApiRequestError if the API endpoint returned an error.

If the used http.Client completes with an error when making a REST call, this method will complete with the same error.

Implementation

async.Future<GenerateAccessTokenResponse> generateAccessToken(
  core.String environment, {
  core.String? expireTime,
  core.String? ttl,
  core.String? $fields,
}) async {
  final queryParams_ = <core.String, core.List<core.String>>{
    'expireTime': ?expireTime == null ? null : [expireTime],
    'ttl': ?ttl == null ? null : [ttl],
    'fields': ?$fields == null ? null : [$fields],
  };

  final url_ =
      'v1/' + core.Uri.encodeFull('$environment') + ':generateAccessToken';

  final response_ = await _requester.request(
    url_,
    'GET',
    queryParams: queryParams_,
  );
  return GenerateAccessTokenResponse.fromJson(
    response_ as core.Map<core.String, core.dynamic>,
  );
}