sipeed/picoclaw · error
userinfo request failed
Error message
userinfo request failed: %s
What it means
Status guard in fetchGoogleUserEmail: the userinfo endpoint returned a non-200 status, so the access token was rejected by Google — most commonly 401 (expired/revoked token) or 403 (insufficient scope). The response body (included verbatim as %s) carries Google's error detail; the email fetch aborts before parsing.
Solutions
- Refresh the access token and retry (it may have expired between auth and userinfo call)
- Re-authenticate with picoclaw auth login if the token was revoked
- Request the email/userinfo scope during login if 403 is returned
- Read the body detail to distinguish invalid_token from insufficient_scope
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at cmd/picoclaw/internal/auth/helpers.go:256 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of sipeed/picoclaw@49183d7e8d (2026-08-15).
Data as JSON: /api/errors/01012d97fa50a77d.
Report an issue: GitHub.
Appendix: source
Thrown at cmd/picoclaw/internal/auth/helpers.go:256
req, err := http.NewRequest("GET", "https://www.googleapis.com/oauth2/v2/userinfo", nil)
if err != nil {
return "", err
}
req.Header.Set("Authorization", "Bearer "+accessToken)
client := &http.Client{Timeout: 10 * time.Second}
resp, err := client.Do(req)
if err != nil {
return "", err
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
return "", fmt.Errorf("reading userinfo response: %w", err)
}
if resp.StatusCode != http.StatusOK {
return "", fmt.Errorf("userinfo request failed: %s", string(body))
}
var userInfo struct {
Email string `json:"email"`
}
if err := json.Unmarshal(body, &userInfo); err != nil {
return "", err
}
return userInfo.Email, nil
}
func authLoginPasteToken(provider string) error {
cred, err := auth.LoginPasteToken(provider, os.Stdin)
if err != nil {
return fmt.Errorf("login failed: %w", err)
}
if err = auth.SetCredential(provider, cred); err != nil {View on GitHub (pinned to 49183d7e8d)