You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
sysPromptInput:=fmt.Sprintf(`{"message":%q,"fields":""}`, fmt.Sprintf("Opening browser to %s. If there is an issue, paste this link into a browser manually.", u.String()))
Input: fmt.Sprintf(`{"metadata":%s,"message":%q}`, b, fmt.Sprintf("Opening browser to %s. If there is an issue, paste this link into a browser manually.", u.String())),
194
200
})
195
201
iferr!=nil {
196
202
fmt.Printf("failed to run sys.prompt: %v\n", err)
197
203
os.Exit(1)
198
204
}
199
205
200
-
if_, err=run.Text(); err!=nil {
206
+
out, err:=run.Text()
207
+
iferr!=nil {
201
208
fmt.Printf("failed to get text: %v\n", err)
202
209
os.Exit(1)
203
210
}
204
211
205
-
// Open the user's browser so that they can authorize the app.
206
-
_=browser.OpenURL(u.String())
212
+
varmmap[string]string
213
+
_=json.Unmarshal([]byte(out), &m)
214
+
215
+
ifm["handled"] !="true" {
216
+
// Open the user's browser so that they can authorize the app.
217
+
_=browser.OpenURL(u.String())
218
+
}
207
219
208
220
t:=time.NewTicker(2*time.Second)
209
-
for {
210
-
select {
211
-
case<-sigCtx.Done():
212
-
fmt.Println("canceled")
221
+
forranget.C {
222
+
// Construct the request to get the token from the gateway.
223
+
req, err:=http.NewRequest("GET", tokenURL, nil)
224
+
iferr!=nil {
225
+
fmt.Printf("failed to create request: %v\n", err)
213
226
os.Exit(1)
214
-
case<-t.C:
215
-
// Construct the request to get the token from the gateway.
216
-
req, err:=http.NewRequest("GET", tokenURL, nil)
217
-
iferr!=nil {
218
-
fmt.Printf("failed to create request: %v\n", err)
219
-
os.Exit(1)
220
-
}
221
-
222
-
q=req.URL.Query()
223
-
q.Set("state", state)
224
-
q.Set("verifier", verifier)
225
-
req.URL.RawQuery=q.Encode()
226
-
227
-
// Send the request to the gateway.
228
-
now:=time.Now()
229
-
resp, err:=http.DefaultClient.Do(req)
230
-
iferr!=nil {
231
-
fmt.Fprintf(os.Stderr, "failed to send request: %v\n", err)
232
-
continue
233
-
}
234
-
235
-
ifresp.StatusCode!=http.StatusOK {
236
-
fmt.Fprintf(os.Stderr, "unexpected status code: %d\n", resp.StatusCode)
0 commit comments