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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR fixes from #1812 #1828

Merged
merged 3 commits into from Jul 26, 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
8 changes: 7 additions & 1 deletion src/app/credential-internal.ts
Expand Up @@ -437,7 +437,13 @@ function requestAccessToken(client: HttpClient, request: HttpRequestConfig): Pro
*/
function requestIDToken(client: HttpClient, request: HttpRequestConfig): Promise<string> {
return client.send(request).then((resp) => {
return resp.text || '';
if (!resp.text) {
throw new FirebaseAppError(
AppErrorCodes.INVALID_CREDENTIAL,
'Unexpected response while fetching id token: response.text is undefined',
);
}
return resp.text;
}).catch((err) => {
throw new FirebaseAppError(AppErrorCodes.INVALID_CREDENTIAL, getErrorMessage(err));
});
Expand Down
2 changes: 1 addition & 1 deletion src/functions/functions-api-client-internal.ts
Expand Up @@ -231,7 +231,7 @@ export class FunctionsApiClient {
: await this.getUrl(resources, FIREBASE_FUNCTION_URL_FORMAT);
task.httpRequest.url = functionUrl;
// When run from a deployed extension, we should be using ComputeEngineCredentials
if (extensionId && this.app.options.credential instanceof ComputeEngineCredential) {
if (validator.isNonEmptyString(extensionId) && this.app.options.credential instanceof ComputeEngineCredential) {
const idToken = await this.app.options.credential.getIDToken(functionUrl);
task.httpRequest.headers = { ...task.httpRequest.headers, 'Authorization': `Bearer ${idToken}` };
// Don't send httpRequest.oidcToken if we set Authorization header, or Cloud Tasks will overwrite it.
Expand Down