Skip to content

Commit

Permalink
Add header to http/2 calls
Browse files Browse the repository at this point in the history
  • Loading branch information
lahirumaramba committed Nov 7, 2024
1 parent e886df8 commit 302d0d7
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/utils/api-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1112,6 +1112,15 @@ export class AuthorizedHttp2Client extends Http2Client {
const authHeader = 'Authorization';
requestCopy.headers[authHeader] = `Bearer ${token}`;

let quotaProjectId: string | undefined;
if (this.app.options.credential instanceof ApplicationDefaultCredential){
quotaProjectId = this.app.options.credential.getQuotaProjectId();
}
quotaProjectId = process.env.GOOGLE_CLOUD_QUOTA_PROJECT || undefined;
if (!requestCopy.headers['x-goog-user-project'] && validator.isNonEmptyString(quotaProjectId)) {
requestCopy.headers['x-goog-user-project'] = quotaProjectId;
}

return super.send(requestCopy);
});
}
Expand Down

0 comments on commit 302d0d7

Please sign in to comment.