Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor!: remove deprecated DeprecatedGetClientOptions #1393

Merged
merged 2 commits into from Apr 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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