Skip to content

Commit 302d0d7

Browse files
committed
Add header to http/2 calls
1 parent e886df8 commit 302d0d7

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/utils/api-request.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,6 +1112,15 @@ export class AuthorizedHttp2Client extends Http2Client {
11121112
const authHeader = 'Authorization';
11131113
requestCopy.headers[authHeader] = `Bearer ${token}`;
11141114

1115+
let quotaProjectId: string | undefined;
1116+
if (this.app.options.credential instanceof ApplicationDefaultCredential){
1117+
quotaProjectId = this.app.options.credential.getQuotaProjectId();
1118+
}
1119+
quotaProjectId = process.env.GOOGLE_CLOUD_QUOTA_PROJECT || undefined;
1120+
if (!requestCopy.headers['x-goog-user-project'] && validator.isNonEmptyString(quotaProjectId)) {
1121+
requestCopy.headers['x-goog-user-project'] = quotaProjectId;
1122+
}
1123+
11151124
return super.send(requestCopy);
11161125
});
11171126
}

0 commit comments

Comments
 (0)