Skip to content
This repository was archived by the owner on Nov 20, 2025. It is now read-only.

Commit b51713c

Browse files
authored
refactor: Consistency Between Langs (#1744)
* refactor: Remove `tokenURL` * refactor: Revert to `googleapis.com`
1 parent 422de68 commit b51713c

File tree

3 files changed

+8
-54
lines changed

3 files changed

+8
-54
lines changed

src/auth/downscopedclient.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,6 @@ export interface CredentialAccessBoundary {
7373
accessBoundary: {
7474
accessBoundaryRules: AccessBoundaryRule[];
7575
};
76-
/**
77-
* An optional STS access token exchange endpoint.
78-
*
79-
* @example
80-
* 'https://sts.googleapis.com/v1/token'
81-
*/
82-
tokenURL?: string | URL;
8376
}
8477

8578
/** Defines an upper bound of permissions on a particular resource. */
@@ -141,11 +134,6 @@ export class DownscopedClient extends AuthClient {
141134
) {
142135
super({...additionalOptions, quotaProjectId});
143136

144-
// extract and remove `tokenURL` as it is not officially a part of the credentialAccessBoundary
145-
this.credentialAccessBoundary = {...credentialAccessBoundary};
146-
const tokenURL = this.credentialAccessBoundary.tokenURL;
147-
delete this.credentialAccessBoundary.tokenURL;
148-
149137
// Check 1-10 Access Boundary Rules are defined within Credential Access
150138
// Boundary.
151139
if (
@@ -174,7 +162,7 @@ export class DownscopedClient extends AuthClient {
174162
}
175163

176164
this.stsCredential = new sts.StsCredentials(
177-
tokenURL || `https://sts.${this.universeDomain}/v1/token`
165+
`https://sts.${this.universeDomain}/v1/token`
178166
);
179167

180168
this.cachedDownscopedAccessToken = null;

src/auth/oauth2client.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -531,12 +531,14 @@ export class OAuth2Client extends AuthClient {
531531
this.redirectUri = opts.redirectUri;
532532

533533
this.endpoints = {
534-
tokenInfoUrl: `https://oauth2.${this.universeDomain}/tokeninfo`,
534+
tokenInfoUrl: 'https://oauth2.googleapis.com/tokeninfo',
535535
oauth2AuthBaseUrl: 'https://accounts.google.com/o/oauth2/v2/auth',
536-
oauth2TokenUrl: `https://oauth2.${this.universeDomain}/token`,
537-
oauth2RevokeUrl: `https://oauth2.${this.universeDomain}/revoke`,
538-
oauth2FederatedSignonPemCertsUrl: `https://www.${this.universeDomain}/oauth2/v1/certs`,
539-
oauth2FederatedSignonJwkCertsUrl: `https://www.${this.universeDomain}/oauth2/v3/certs`,
536+
oauth2TokenUrl: 'https://oauth2.googleapis.com/token',
537+
oauth2RevokeUrl: 'https://oauth2.googleapis.com/revoke',
538+
oauth2FederatedSignonPemCertsUrl:
539+
'https://www.googleapis.com/oauth2/v1/certs',
540+
oauth2FederatedSignonJwkCertsUrl:
541+
'https://www.googleapis.com/oauth2/v3/certs',
540542
oauth2IapPublicKeyUrl: 'https://www.gstatic.com/iap/verify/public_key',
541543
...opts.endpoints,
542544
};

test/test.downscopedclient.ts

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -325,42 +325,6 @@ describe('DownscopedClient', () => {
325325
refreshOptions.eagerRefreshThresholdMillis
326326
);
327327
});
328-
329-
it('should use a tokenURL', async () => {
330-
const tokenURL = new URL('https://my-token-url/v1/token');
331-
const scope = mockStsTokenExchange(
332-
[
333-
{
334-
statusCode: 200,
335-
response: stsSuccessfulResponse,
336-
request: {
337-
grant_type: 'urn:ietf:params:oauth:grant-type:token-exchange',
338-
requested_token_type:
339-
'urn:ietf:params:oauth:token-type:access_token',
340-
subject_token: 'subject_token_0',
341-
subject_token_type:
342-
'urn:ietf:params:oauth:token-type:access_token',
343-
options: JSON.stringify(testClientAccessBoundary),
344-
},
345-
},
346-
],
347-
undefined,
348-
tokenURL.origin
349-
);
350-
351-
const downscopedClient = new DownscopedClient(client, {
352-
...testClientAccessBoundary,
353-
tokenURL,
354-
});
355-
356-
const tokenResponse = await downscopedClient.getAccessToken();
357-
assert.deepStrictEqual(
358-
tokenResponse.token,
359-
stsSuccessfulResponse.access_token
360-
);
361-
362-
scope.done();
363-
});
364328
});
365329

366330
describe('setCredential()', () => {

0 commit comments

Comments
 (0)