@@ -12,7 +12,7 @@ import { Options } from "../../src/options";
1212import { currentOptions , getCommandOptions } from "./options" ;
1313import { EmulatorUiSelections } from "../common/messaging/types" ;
1414import { pluginLogger } from "./logger-wrapper" ;
15- import { setAccessToken } from "../../src/apiv2" ;
15+ import { getAccessToken , setAccessToken } from "../../src/apiv2" ;
1616import {
1717 startAll as startAllEmulators ,
1818 cleanShutdown as stopAllEmulators ,
@@ -56,7 +56,7 @@ export async function requireAuthWrapper(
5656 return (
5757 account &&
5858 account . user . email === optionsUser . email &&
59- account . tokens . access_token === optionsTokens . access_token // TODO: check if this is necessary
59+ account . tokens . refresh_token === optionsTokens . refresh_token // Should check refresh token which is consistent, not access_token which is short lived.
6060 ) ;
6161 }
6262
@@ -80,8 +80,12 @@ export async function requireAuthWrapper(
8080 // over Google login tokens and must be removed if a Google
8181 // account is the current user.
8282 try {
83- setAccessToken ( ) ; // clears the current access token
8483 const userEmail = await requireAuth ( currentOptions . value ) ; // client email
84+ // SetAccessToken is necessary here to ensure that access_tokens are available when:
85+ // - we are using tokens from configstore (aka those set by firebase login), AND
86+ // - we are calling CLI code that skips Command (where we normally call this)
87+
88+ setAccessToken ( await getAccessToken ( ) ) ;
8589 if ( userEmail ) {
8690 pluginLogger . debug ( "User found: " , userEmail ) ;
8791
0 commit comments