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())),
201
207
})
202
208
iferr!=nil {
203
209
fmt.Printf("failed to run sys.prompt: %v\n", err)
204
210
os.Exit(1)
205
211
}
206
212
207
-
if_, err=run.Text(); err!=nil {
213
+
out, err:=run.Text()
214
+
iferr!=nil {
208
215
fmt.Printf("failed to get text: %v\n", err)
209
216
os.Exit(1)
210
217
}
211
218
212
-
// Open the user's browser so that they can authorize the app.
213
-
_=browser.OpenURL(u.String())
219
+
varmmap[string]string
220
+
_=json.Unmarshal([]byte(out), &m)
221
+
222
+
ifm["handled"] !="true" {
223
+
// Open the user's browser so that they can authorize the app.
224
+
_=browser.OpenURL(u.String())
225
+
}
214
226
215
227
t:=time.NewTicker(2*time.Second)
216
-
for {
217
-
select {
218
-
case<-sigCtx.Done():
219
-
fmt.Println("canceled")
228
+
forranget.C {
229
+
// Construct the request to get the token from the gateway.
230
+
req, err:=http.NewRequest("GET", tokenURL, nil)
231
+
iferr!=nil {
232
+
fmt.Printf("failed to create request: %v\n", err)
220
233
os.Exit(1)
221
-
case<-t.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)
226
-
os.Exit(1)
227
-
}
228
-
229
-
q=req.URL.Query()
230
-
q.Set("state", state)
231
-
q.Set("verifier", verifier)
232
-
req.URL.RawQuery=q.Encode()
233
-
234
-
// Send the request to the gateway.
235
-
now:=time.Now()
236
-
resp, err:=http.DefaultClient.Do(req)
237
-
iferr!=nil {
238
-
fmt.Fprintf(os.Stderr, "failed to send request: %v\n", err)
239
-
continue
240
-
}
241
-
242
-
ifresp.StatusCode!=http.StatusOK {
243
-
fmt.Fprintf(os.Stderr, "unexpected status code: %d\n", resp.StatusCode)
0 commit comments