diff --git a/src/auth.ts b/src/auth.ts index 608837fb6fa..6f13cfe36fd 100644 --- a/src/auth.ts +++ b/src/auth.ts @@ -110,13 +110,10 @@ export function getAllAccounts(): Account[] { * @param options options object. * @param account account to make active. */ -export function setActiveAccount(options: any, account: Account) { +export async function setActiveAccount(options: any, account: Account) { if (account.tokens.refresh_token) { setRefreshToken(account.tokens.refresh_token); - } - - if (account.tokens.access_token) { - setAccessToken(account.tokens.access_token); + setAccessToken(await apiv2.getAccessToken()); } options.user = account.user; diff --git a/src/command.ts b/src/command.ts index 7d400377367..427cc31e885 100644 --- a/src/command.ts +++ b/src/command.ts @@ -319,7 +319,7 @@ export class Command { const activeAccount = selectAccount(account, projectRoot); if (activeAccount) { - setActiveAccount(options, activeAccount); + await setActiveAccount(options, activeAccount); } this.applyRC(options); diff --git a/src/init/features/account.ts b/src/init/features/account.ts index a40184bb7d3..506a46074f3 100644 --- a/src/init/features/account.ts +++ b/src/init/features/account.ts @@ -73,7 +73,7 @@ export async function doSetup(setup: any, config: any, options: any): Promise { throw new FirebaseError(AUTH_ERROR_MESSAGE); } - setActiveAccount(options, { user, tokens }); + await setActiveAccount(options, { user, tokens }); return user.email; }