@@ -112,7 +112,9 @@ func loginCmd(ctx context.Context, p loginParams) error {
112112 export SRC_ACCESS_TOKEN=(your access token)
113113
114114 To verify that it's working, run the login command again.
115- ` , endpointArg , endpointArg )
115+
116+ Alternatively, you can try logging in using OAuth by running: src login --oauth %s
117+ ` , endpointArg , endpointArg , endpointArg )
116118
117119 if cfg .ConfigFilePath != "" {
118120 fmt .Fprintln (out )
@@ -121,8 +123,17 @@ func loginCmd(ctx context.Context, p loginParams) error {
121123
122124 noToken := cfg .AccessToken == ""
123125 endpointConflict := endpointArg != cfg .Endpoint
124-
125- cfg .Endpoint = endpointArg
126+ if ! p .useOAuth && (noToken || endpointConflict ) {
127+ fmt .Fprintln (out )
128+ switch {
129+ case noToken :
130+ printProblem ("No access token is configured." )
131+ case endpointConflict :
132+ printProblem (fmt .Sprintf ("The configured endpoint is %s, not %s." , cfg .Endpoint , endpointArg ))
133+ }
134+ fmt .Fprintln (out , createAccessTokenMessage )
135+ return cmderrors .ExitCode1
136+ }
126137
127138 if p .useOAuth {
128139 token , err := runOAuthDeviceFlow (ctx , endpointArg , out , p .deviceFlowClient )
@@ -146,16 +157,6 @@ func loginCmd(ctx context.Context, p loginParams) error {
146157 ProxyPath : cfg .ProxyPath ,
147158 OAuthToken : token ,
148159 })
149- } else if noToken || endpointConflict {
150- fmt .Fprintln (out )
151- switch {
152- case noToken :
153- printProblem ("No access token is configured." )
154- case endpointConflict :
155- printProblem (fmt .Sprintf ("The configured endpoint is %s, not %s." , cfg .Endpoint , endpointArg ))
156- }
157- fmt .Fprintln (out , createAccessTokenMessage )
158- return cmderrors .ExitCode1
159160 }
160161
161162 // See if the user is already authenticated.
0 commit comments