Skip to content

Commit

Permalink
refactor!: remove deprecated DeprecatedGetClientOptions (#1393)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielbankhead committed Apr 12, 2022
1 parent 416ea93 commit 9c02941
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 26 deletions.
10 changes: 1 addition & 9 deletions src/auth/googleauth.ts
Expand Up @@ -59,9 +59,6 @@ export interface CredentialCallback {
(err: Error | null, result?: JSONClient): void;
}

// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface DeprecatedGetClientOptions {}

export interface ADCCallback {
(err: Error | null, credential?: AuthClient, projectId?: string | null): void;
}
Expand Down Expand Up @@ -790,12 +787,7 @@ export class GoogleAuth<T extends AuthClient = JSONClient> {
* Automatically obtain a client based on the provided configuration. If no
* options were passed, use Application Default Credentials.
*/
async getClient(options?: DeprecatedGetClientOptions) {
if (options) {
throw new Error(
'Passing options to getClient is forbidden in v5.0.0. Use new GoogleAuth(opts) instead.'
);
}
async getClient() {
if (!this.cachedCredential) {
if (this.jsonContent) {
this._cacheClientFromJSON(this.jsonContent, this.clientOptions);
Expand Down
1 change: 0 additions & 1 deletion src/auth/oauth2client.ts
Expand Up @@ -709,7 +709,6 @@ export class OAuth2Client extends AuthClient {
/**
* Retrieves the access token using refresh token
*
* @deprecated use getRequestHeaders instead.
* @param callback callback
*/
refreshAccessToken(): Promise<RefreshAccessTokenResponse>;
Expand Down
8 changes: 0 additions & 8 deletions test/test.googleauth.ts
Expand Up @@ -1496,14 +1496,6 @@ describe('googleauth', () => {
);
});

it('should throw if options are passed to getClient()', async () => {
const auth = new GoogleAuth();
await assert.rejects(
auth.getClient({hello: 'world'}),
/Passing options to getClient is forbidden in v5.0.0/
);
});

it('getRequestHeaders populates x-goog-user-project with quota_project if present', async () => {
const tokenReq = mockApplicationDefaultCredentials(
'./test/fixtures/config-with-quota'
Expand Down
8 changes: 0 additions & 8 deletions test/test.oauth2.ts
Expand Up @@ -900,14 +900,6 @@ describe('oauth2', () => {
});
});

it('should not emit warning on refreshAccessToken', async () => {
let warned = false;
sandbox.stub(process, 'emitWarning').callsFake(() => (warned = true));
client.refreshAccessToken(() => {
assert.strictEqual(warned, false);
});
});

it('should return error in callback on refreshAccessToken', done => {
client.refreshAccessToken((err, result) => {
assert.strictEqual(err!.message, 'No refresh token is set.');
Expand Down

0 comments on commit 9c02941

Please sign in to comment.