@@ -8,7 +8,6 @@ import * as vscode from "vscode";
88
99import { errToStr } from "./api/api-helper" ;
1010import { CoderApi } from "./api/coderApi" ;
11- import { needToken } from "./api/utils" ;
1211import { Commands } from "./commands" ;
1312import { ServiceContainer } from "./core/container" ;
1413import { type SecretsManager } from "./core/secretsManager" ;
@@ -449,15 +448,14 @@ async function setupDeploymentFromUri(
449448
450449 // If the token is missing we will get a 401 later and the user will be
451450 // prompted to sign in again, so we do not need to ensure it is set now.
452- // For non-token auth, we write a blank token since the `vscodessh`
453- // command currently always requires a token file. However, if there is
454- // a query parameter for non-token auth go ahead and use it anyway;
455- let token : string | undefined = params . get ( "token" ) ?? undefined ;
456- if ( token === undefined ) {
457- if ( needToken ( vscode . workspace . getConfiguration ( ) ) ) {
458- token = ( await secretsManager . getSessionAuth ( safeHost ) ) ?. token ;
459- } else {
460- token = "" ;
451+ const token : string | null = params . get ( "token" ) ;
452+ if ( token === null ) {
453+ // We need to ensure there is at least an entry for this in storage
454+ // so that we know what URL to prompt the user with when logging in.
455+ const auth = await secretsManager . getSessionAuth ( safeHost ) ;
456+ if ( ! auth ) {
457+ // Racy, we could accidentally overwrite the token that is written in the meantime.
458+ await secretsManager . setSessionAuth ( safeHost , { url, token : "" } ) ;
461459 }
462460 } else {
463461 await secretsManager . setSessionAuth ( safeHost , { url, token } ) ;
0 commit comments