diff --git a/esi_sso.go b/esi_sso.go index 02a6a35..3e0508c 100644 --- a/esi_sso.go +++ b/esi_sso.go @@ -248,6 +248,7 @@ func (s *ESISSO) StartCallbackServerAsync() error { mux := http.NewServeMux() mux.HandleFunc(u.Path, func(w http.ResponseWriter, r *http.Request) { + fmt.Printf("Callback received: %s %s\n", r.Method, r.URL.String()) if r.Method != http.MethodGet { w.WriteHeader(http.StatusMethodNotAllowed) return @@ -256,18 +257,23 @@ func (s *ESISSO) StartCallbackServerAsync() error { code := q.Get("code") st := q.Get("state") if code == "" || st == "" || st != s.state { + fmt.Printf("Invalid SSO response: code=%s, state=%s, expected_state=%s\n", code, st, s.state) w.WriteHeader(http.StatusBadRequest) _, _ = w.Write([]byte("Invalid SSO response")) return } + fmt.Printf("Exchanging token for code: %s\n", code) if err := s.exchangeToken(r.Context(), code); err != nil { + fmt.Printf("Token exchange failed: %v\n", err) w.WriteHeader(http.StatusInternalServerError) _, _ = w.Write([]byte("Token exchange failed: " + err.Error())) return } - _, _ = io.WriteString(w, "Login successful. You can close this window.") + fmt.Printf("Login successful for character: %s (%d)\n", s.characterName, s.characterID) + w.Header().Set("Content-Type", "text/html") + _, _ = io.WriteString(w, "

Login successful!

You can close this window.

") go func() { - time.Sleep(200 * time.Millisecond) + time.Sleep(1 * time.Second) _ = s.server.Shutdown(context.Background()) }() }) @@ -277,6 +283,7 @@ func (s *ESISSO) StartCallbackServerAsync() error { return err } + fmt.Printf("Callback server listening on %s%s\n", hostPort, u.Path) s.server = &http.Server{Handler: mux} go func() { _ = s.server.Serve(ln) }() return nil