Skip to content

Commit

Permalink
feat(sts): update the API
Browse files Browse the repository at this point in the history
#### sts:v1

The following keys were added:
- resources.v1.methods.introspect.description
- resources.v1.methods.introspect.flatPath
- resources.v1.methods.introspect.httpMethod
- resources.v1.methods.introspect.id
- resources.v1.methods.introspect.parameterOrder
- resources.v1.methods.introspect.path
- resources.v1.methods.introspect.request.$ref
- resources.v1.methods.introspect.response.$ref
- schemas.GoogleIdentityStsV1IntrospectTokenRequest.description
- schemas.GoogleIdentityStsV1IntrospectTokenRequest.id
- schemas.GoogleIdentityStsV1IntrospectTokenRequest.properties.token.description
- schemas.GoogleIdentityStsV1IntrospectTokenRequest.properties.token.type
- schemas.GoogleIdentityStsV1IntrospectTokenRequest.properties.tokenTypeHint.description
- schemas.GoogleIdentityStsV1IntrospectTokenRequest.properties.tokenTypeHint.type
- schemas.GoogleIdentityStsV1IntrospectTokenRequest.type
- schemas.GoogleIdentityStsV1IntrospectTokenResponse.description
- schemas.GoogleIdentityStsV1IntrospectTokenResponse.id
- schemas.GoogleIdentityStsV1IntrospectTokenResponse.properties.active.description
- schemas.GoogleIdentityStsV1IntrospectTokenResponse.properties.active.type
- schemas.GoogleIdentityStsV1IntrospectTokenResponse.properties.client_id.description
- schemas.GoogleIdentityStsV1IntrospectTokenResponse.properties.client_id.type
- schemas.GoogleIdentityStsV1IntrospectTokenResponse.properties.exp.description
- schemas.GoogleIdentityStsV1IntrospectTokenResponse.properties.exp.format
- schemas.GoogleIdentityStsV1IntrospectTokenResponse.properties.exp.type
- schemas.GoogleIdentityStsV1IntrospectTokenResponse.properties.iat.description
- schemas.GoogleIdentityStsV1IntrospectTokenResponse.properties.iat.format
- schemas.GoogleIdentityStsV1IntrospectTokenResponse.properties.iat.type
- schemas.GoogleIdentityStsV1IntrospectTokenResponse.properties.iss.description
- schemas.GoogleIdentityStsV1IntrospectTokenResponse.properties.iss.type
- schemas.GoogleIdentityStsV1IntrospectTokenResponse.properties.scope.description
- schemas.GoogleIdentityStsV1IntrospectTokenResponse.properties.scope.type
- schemas.GoogleIdentityStsV1IntrospectTokenResponse.properties.sub.description
- schemas.GoogleIdentityStsV1IntrospectTokenResponse.properties.sub.type
- schemas.GoogleIdentityStsV1IntrospectTokenResponse.properties.username.description
- schemas.GoogleIdentityStsV1IntrospectTokenResponse.properties.username.type
- schemas.GoogleIdentityStsV1IntrospectTokenResponse.type
  • Loading branch information
yoshi-automation authored and JustinBeckwith committed Jun 18, 2021
1 parent 3ab53b0 commit fdb995b
Show file tree
Hide file tree
Showing 2 changed files with 275 additions and 1 deletion.
73 changes: 72 additions & 1 deletion discovery/sts-v1.json
Expand Up @@ -98,6 +98,21 @@
"resources": {
"v1": {
"methods": {
"introspect": {
"description": "Gets information about a Google OAuth 2.0 access token issued by the Google Cloud [Security Token Service API](https://cloud.google.com/iam/docs/reference/sts/rest).",
"flatPath": "v1/introspect",
"httpMethod": "POST",
"id": "sts.introspect",
"parameterOrder": [],
"parameters": {},
"path": "v1/introspect",
"request": {
"$ref": "GoogleIdentityStsV1IntrospectTokenRequest"
},
"response": {
"$ref": "GoogleIdentityStsV1IntrospectTokenResponse"
}
},
"token": {
"description": "Exchanges a credential for a Google OAuth 2.0 access token. The token asserts an external identity within a workload identity pool, or it applies a Credential Access Boundary to a Google access token. When you call this method, do not send the `Authorization` HTTP header in the request. This method does not require the `Authorization` header, and using the header can cause the request to fail.",
"flatPath": "v1/token",
Expand All @@ -116,7 +131,7 @@
}
}
},
"revision": "20210517",
"revision": "20210613",
"rootUrl": "https://sts.googleapis.com/",
"schemas": {
"GoogleIdentityStsV1ExchangeTokenRequest": {
Expand Down Expand Up @@ -177,6 +192,62 @@
}
},
"type": "object"
},
"GoogleIdentityStsV1IntrospectTokenRequest": {
"description": "Request message for IntrospectToken.",
"id": "GoogleIdentityStsV1IntrospectTokenRequest",
"properties": {
"token": {
"description": "Required. The OAuth 2.0 security token issued by the Security Token Service API.",
"type": "string"
},
"tokenTypeHint": {
"description": "Optional. The type of the given token. Supported values are `urn:ietf:params:oauth:token-type:access_token` and `access_token`.",
"type": "string"
}
},
"type": "object"
},
"GoogleIdentityStsV1IntrospectTokenResponse": {
"description": "Response message for IntrospectToken.",
"id": "GoogleIdentityStsV1IntrospectTokenResponse",
"properties": {
"active": {
"description": "A boolean value that indicates whether the provided access token is currently active.",
"type": "boolean"
},
"client_id": {
"description": "The client identifier for the OAuth 2.0 client that requested the provided token.",
"type": "string"
},
"exp": {
"description": "The expiration timestamp, measured in the number of seconds since January 1 1970 UTC, indicating when this token will expire.",
"format": "int64",
"type": "string"
},
"iat": {
"description": "The issued timestamp, measured in the number of seconds since January 1 1970 UTC, indicating when this token was originally issued.",
"format": "int64",
"type": "string"
},
"iss": {
"description": "The issuer of the provided token.",
"type": "string"
},
"scope": {
"description": "A list of scopes associated with the provided token.",
"type": "string"
},
"sub": {
"description": "The unique user ID associated with the provided token. For Google Accounts, this value is based on the Google Account's user ID. For federated identities, this value is based on the identity pool ID and the value of the mapped `google.subject` attribute.",
"type": "string"
},
"username": {
"description": "The human-readable identifier for the token principal subject. For example, if the provided token is associated with a workload identity pool, this field contains a value in the following format: `principal://iam.googleapis.com/projects//locations//workloadIdentityPools//subject/`",
"type": "string"
}
},
"type": "object"
}
},
"servicePath": "",
Expand Down
203 changes: 203 additions & 0 deletions src/apis/sts/v1.ts
Expand Up @@ -179,13 +179,210 @@ export namespace sts_v1 {
*/
token_type?: string | null;
}
/**
* Request message for IntrospectToken.
*/
export interface Schema$GoogleIdentityStsV1IntrospectTokenRequest {
/**
* Required. The OAuth 2.0 security token issued by the Security Token Service API.
*/
token?: string | null;
/**
* Optional. The type of the given token. Supported values are `urn:ietf:params:oauth:token-type:access_token` and `access_token`.
*/
tokenTypeHint?: string | null;
}
/**
* Response message for IntrospectToken.
*/
export interface Schema$GoogleIdentityStsV1IntrospectTokenResponse {
/**
* A boolean value that indicates whether the provided access token is currently active.
*/
active?: boolean | null;
/**
* The client identifier for the OAuth 2.0 client that requested the provided token.
*/
client_id?: string | null;
/**
* The expiration timestamp, measured in the number of seconds since January 1 1970 UTC, indicating when this token will expire.
*/
exp?: string | null;
/**
* The issued timestamp, measured in the number of seconds since January 1 1970 UTC, indicating when this token was originally issued.
*/
iat?: string | null;
/**
* The issuer of the provided token.
*/
iss?: string | null;
/**
* A list of scopes associated with the provided token.
*/
scope?: string | null;
/**
* The unique user ID associated with the provided token. For Google Accounts, this value is based on the Google Account's user ID. For federated identities, this value is based on the identity pool ID and the value of the mapped `google.subject` attribute.
*/
sub?: string | null;
/**
* The human-readable identifier for the token principal subject. For example, if the provided token is associated with a workload identity pool, this field contains a value in the following format: `principal://iam.googleapis.com/projects//locations//workloadIdentityPools//subject/`
*/
username?: string | null;
}

export class Resource$V1 {
context: APIRequestContext;
constructor(context: APIRequestContext) {
this.context = context;
}

/**
* Gets information about a Google OAuth 2.0 access token issued by the Google Cloud [Security Token Service API](https://cloud.google.com/iam/docs/reference/sts/rest).
* @example
* ```js
* // Before running the sample:
* // - Enable the API at:
* // https://console.developers.google.com/apis/api/sts.googleapis.com
* // - Login into gcloud by running:
* // `$ gcloud auth application-default login`
* // - Install the npm module by running:
* // `$ npm install googleapis`
*
* const {google} = require('googleapis');
* const sts = google.sts('v1');
*
* async function main() {
* const auth = new google.auth.GoogleAuth({
* // Scopes can be specified either as an array or as a single, space-delimited string.
* scopes: [],
* });
*
* // Acquire an auth client, and bind it to all future calls
* const authClient = await auth.getClient();
* google.options({auth: authClient});
*
* // Do the magic
* const res = await sts.introspect({
* // Request body metadata
* requestBody: {
* // request body parameters
* // {
* // "token": "my_token",
* // "tokenTypeHint": "my_tokenTypeHint"
* // }
* },
* });
* console.log(res.data);
*
* // Example response
* // {
* // "active": false,
* // "client_id": "my_client_id",
* // "exp": "my_exp",
* // "iat": "my_iat",
* // "iss": "my_iss",
* // "scope": "my_scope",
* // "sub": "my_sub",
* // "username": "my_username"
* // }
* }
*
* main().catch(e => {
* console.error(e);
* throw e;
* });
*
* ```
*
* @param params - Parameters for request
* @param options - Optionally override request options, such as `url`, `method`, and `encoding`.
* @param callback - Optional callback that handles the response.
* @returns A promise if used with async/await, or void if used with a callback.
*/
introspect(
params: Params$Resource$V1$Introspect,
options: StreamMethodOptions
): GaxiosPromise<Readable>;
introspect(
params?: Params$Resource$V1$Introspect,
options?: MethodOptions
): GaxiosPromise<Schema$GoogleIdentityStsV1IntrospectTokenResponse>;
introspect(
params: Params$Resource$V1$Introspect,
options: StreamMethodOptions | BodyResponseCallback<Readable>,
callback: BodyResponseCallback<Readable>
): void;
introspect(
params: Params$Resource$V1$Introspect,
options:
| MethodOptions
| BodyResponseCallback<Schema$GoogleIdentityStsV1IntrospectTokenResponse>,
callback: BodyResponseCallback<Schema$GoogleIdentityStsV1IntrospectTokenResponse>
): void;
introspect(
params: Params$Resource$V1$Introspect,
callback: BodyResponseCallback<Schema$GoogleIdentityStsV1IntrospectTokenResponse>
): void;
introspect(
callback: BodyResponseCallback<Schema$GoogleIdentityStsV1IntrospectTokenResponse>
): void;
introspect(
paramsOrCallback?:
| Params$Resource$V1$Introspect
| BodyResponseCallback<Schema$GoogleIdentityStsV1IntrospectTokenResponse>
| BodyResponseCallback<Readable>,
optionsOrCallback?:
| MethodOptions
| StreamMethodOptions
| BodyResponseCallback<Schema$GoogleIdentityStsV1IntrospectTokenResponse>
| BodyResponseCallback<Readable>,
callback?:
| BodyResponseCallback<Schema$GoogleIdentityStsV1IntrospectTokenResponse>
| BodyResponseCallback<Readable>
):
| void
| GaxiosPromise<Schema$GoogleIdentityStsV1IntrospectTokenResponse>
| GaxiosPromise<Readable> {
let params = (paramsOrCallback || {}) as Params$Resource$V1$Introspect;
let options = (optionsOrCallback || {}) as MethodOptions;

if (typeof paramsOrCallback === 'function') {
callback = paramsOrCallback;
params = {} as Params$Resource$V1$Introspect;
options = {};
}

if (typeof optionsOrCallback === 'function') {
callback = optionsOrCallback;
options = {};
}

const rootUrl = options.rootUrl || 'https://sts.googleapis.com/';
const parameters = {
options: Object.assign(
{
url: (rootUrl + '/v1/introspect').replace(/([^:]\/)\/+/g, '$1'),
method: 'POST',
},
options
),
params,
requiredParams: [],
pathParams: [],
context: this.context,
};
if (callback) {
createAPIRequest<Schema$GoogleIdentityStsV1IntrospectTokenResponse>(
parameters,
callback as BodyResponseCallback<unknown>
);
} else {
return createAPIRequest<Schema$GoogleIdentityStsV1IntrospectTokenResponse>(
parameters
);
}
}

/**
* Exchanges a credential for a Google OAuth 2.0 access token. The token asserts an external identity within a workload identity pool, or it applies a Credential Access Boundary to a Google access token. When you call this method, do not send the `Authorization` HTTP header in the request. This method does not require the `Authorization` header, and using the header can cause the request to fail.
* @example
Expand Down Expand Up @@ -335,6 +532,12 @@ export namespace sts_v1 {
}
}

export interface Params$Resource$V1$Introspect extends StandardParameters {
/**
* Request body metadata
*/
requestBody?: Schema$GoogleIdentityStsV1IntrospectTokenRequest;
}
export interface Params$Resource$V1$Token extends StandardParameters {
/**
* Request body metadata
Expand Down

0 comments on commit fdb995b

Please sign in to comment.