oauthtoken method

Exchanges a credential that represents the resource owner's authorization for a Google-generated OAuth 2.0 access token or refreshes an accesstoken following the OAuth 2.0 authorization framework The credential can be one of the following: - An authorization code issued by the workforce identity federation authorization endpoint - A refresh token issued by this endpoint This endpoint is only meant to be called by the Google Cloud CLI.

Also note that this API only accepts the authorization code issued for workforce pools.

request - The metadata request object.

Request parameters:

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

Completes with a GoogleIdentityStsV1ExchangeOauthTokenResponse.

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<GoogleIdentityStsV1ExchangeOauthTokenResponse> oauthtoken(
  GoogleIdentityStsV1ExchangeOauthTokenRequest request, {
  core.String? $fields,
}) async {
  final body_ = convert.json.encode(request);
  final queryParams_ = <core.String, core.List<core.String>>{
    if ($fields != null) 'fields': [$fields],
  };

  const url_ = 'v1/oauthtoken';

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