@@ -143,6 +143,7 @@ export class Commands {
143143 const inputUrl = args [ 0 ]
144144 const inputToken = args [ 1 ]
145145 const inputLabel = args [ 2 ]
146+ const isAutologin = typeof args [ 3 ] === "undefined" ? false : Boolean ( args [ 3 ] )
146147
147148 const url = await this . maybeAskUrl ( inputUrl )
148149 if ( ! url ) {
@@ -155,7 +156,7 @@ export class Commands {
155156 const label = typeof inputLabel === "undefined" ? toSafeHost ( url ) : inputLabel
156157
157158 // Try to get a token from the user, if we need one, and their user.
158- const res = await this . maybeAskToken ( url , inputToken )
159+ const res = await this . maybeAskToken ( url , inputToken , isAutologin )
159160 if ( ! res ) {
160161 return // The user aborted, or unable to auth.
161162 }
@@ -202,7 +203,11 @@ export class Commands {
202203 * token. Null means the user aborted or we were unable to authenticate with
203204 * mTLS (in the latter case, an error notification will have been displayed).
204205 */
205- private async maybeAskToken ( url : string , token : string ) : Promise < { user : User ; token : string } | null > {
206+ private async maybeAskToken (
207+ url : string ,
208+ token : string ,
209+ isAutologin : boolean ,
210+ ) : Promise < { user : User ; token : string } | null > {
206211 const restClient = await makeCoderSdk ( url , token , this . storage )
207212 if ( ! needToken ( ) ) {
208213 try {
@@ -212,11 +217,15 @@ export class Commands {
212217 return { token : "" , user }
213218 } catch ( err ) {
214219 const message = getErrorMessage ( err , "no response from the server" )
215- this . vscodeProposed . window . showErrorMessage ( "Failed to log in" , {
216- detail : message ,
217- modal : true ,
218- useCustom : true ,
219- } )
220+ if ( isAutologin ) {
221+ this . storage . writeToCoderOutputChannel ( `Failed to log in to Coder server: ${ message } ` )
222+ } else {
223+ this . vscodeProposed . window . showErrorMessage ( "Failed to log in to Coder server" , {
224+ detail : message ,
225+ modal : true ,
226+ useCustom : true ,
227+ } )
228+ }
220229 // Invalid certificate, most likely.
221230 return null
222231 }
0 commit comments