@@ -18,7 +18,7 @@ import {firstPartyDev, themeToken} from '../../public/node/context/local.js'
1818import { AbortError , BugError } from '../../public/node/error.js'
1919import { normalizeStoreFqdn , identityFqdn } from '../../public/node/context/fqdn.js'
2020import { getIdentityTokenInformation , getPartnersToken } from '../../public/node/environment.js'
21- import { AdminSession } from '../../public/node/session.js'
21+ import { AdminSession , logout } from '../../public/node/session.js'
2222import { nonRandomUUID } from '../../public/node/crypto.js'
2323
2424/**
@@ -197,8 +197,9 @@ ${outputToken.json(applications)}
197197
198198 let newSession = { }
199199
200- function throwOnNoPrompt ( ) {
200+ async function throwOnNoPrompt ( ) {
201201 if ( ! noPrompt ) return
202+ await logout ( )
202203 throw new AbortError (
203204 `The currently available CLI credentials are invalid.
204205
@@ -208,7 +209,7 @@ The CLI is currently unable to prompt for reauthentication.`,
208209 }
209210
210211 if ( validationResult === 'needs_full_auth' ) {
211- throwOnNoPrompt ( )
212+ await throwOnNoPrompt ( )
212213 outputDebug ( outputContent `Initiating the full authentication flow...` )
213214 newSession = await executeCompleteFlow ( applications , fqdn )
214215 } else if ( validationResult === 'needs_refresh' || forceRefresh ) {
@@ -217,7 +218,7 @@ The CLI is currently unable to prompt for reauthentication.`,
217218 newSession = await refreshTokens ( fqdnSession . identity , applications , fqdn )
218219 } catch ( error ) {
219220 if ( error instanceof InvalidGrantError ) {
220- throwOnNoPrompt ( )
221+ await throwOnNoPrompt ( )
221222 newSession = await executeCompleteFlow ( applications , fqdn )
222223 } else if ( error instanceof InvalidRequestError ) {
223224 await secureStore . remove ( )
0 commit comments