package github import ( "context" "encoding/json" "fmt" ) // userResponse is the GitHub API response for the authenticated user. type userResponse struct { Login string `json:"login"` } // GetAuthenticatedUser returns the login of the currently authenticated user. func (c *Client) GetAuthenticatedUser(ctx context.Context) (string, error) { reqURL := fmt.Sprintf("%s/user", c.baseURL) body, err := c.doGet(ctx, reqURL) if err != nil { return "", fmt.Errorf("get authenticated user: %w", err) } var resp userResponse if err := json.Unmarshal(body, &resp); err != nil { return "", fmt.Errorf("parse user response: %w", err) } return resp.Login, nil }