Skip to content

Commit 392c7fe

Browse files
authored
PR fixes from #1812 (#1828)
* PR fixes from #1812 * Remove unused dep
1 parent b5de227 commit 392c7fe

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/app/credential-internal.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,13 @@ function requestAccessToken(client: HttpClient, request: HttpRequestConfig): Pro
437437
*/
438438
function requestIDToken(client: HttpClient, request: HttpRequestConfig): Promise<string> {
439439
return client.send(request).then((resp) => {
440-
return resp.text || '';
440+
if (!resp.text) {
441+
throw new FirebaseAppError(
442+
AppErrorCodes.INVALID_CREDENTIAL,
443+
'Unexpected response while fetching id token: response.text is undefined',
444+
);
445+
}
446+
return resp.text;
441447
}).catch((err) => {
442448
throw new FirebaseAppError(AppErrorCodes.INVALID_CREDENTIAL, getErrorMessage(err));
443449
});

src/functions/functions-api-client-internal.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ export class FunctionsApiClient {
231231
: await this.getUrl(resources, FIREBASE_FUNCTION_URL_FORMAT);
232232
task.httpRequest.url = functionUrl;
233233
// When run from a deployed extension, we should be using ComputeEngineCredentials
234-
if (extensionId && this.app.options.credential instanceof ComputeEngineCredential) {
234+
if (validator.isNonEmptyString(extensionId) && this.app.options.credential instanceof ComputeEngineCredential) {
235235
const idToken = await this.app.options.credential.getIDToken(functionUrl);
236236
task.httpRequest.headers = { ...task.httpRequest.headers, 'Authorization': `Bearer ${idToken}` };
237237
// Don't send httpRequest.oidcToken if we set Authorization header, or Cloud Tasks will overwrite it.

0 commit comments

Comments
 (0)