-
Notifications
You must be signed in to change notification settings - Fork 6
docs(api-clients): add OAuth authentication examples for all SDK languages #245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…uages Add comprehensive OAuth authentication documentation to all four API client libraries (Go, Java, Python, TypeScript). Each includes: - Prerequisites and admin configuration links - Required headers table (Authorization, X-Glean-Auth-Type) - Complete authorization code flow example using idiomatic libraries - Token refresh tips for production use 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Address PR review feedback:
- TypeScript: Add PKCE (code_challenge, code_verifier) and state
verification using openid-client v6 correct API
- Java: Fix Spring Security YAML structure with proper named
registration/provider ("glean") and authorization-grant-type
- Go: Add cryptographic state generation and validation to prevent
CSRF attacks (was using hardcoded "state")
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
| ClientID: os.Getenv("OAUTH_CLIENT_ID"), | ||
| ClientSecret: os.Getenv("OAUTH_CLIENT_SECRET"), | ||
| RedirectURL: "http://localhost:8080/callback", | ||
| Scopes: []string{"openid", "email"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3/5 (strong opinion: non-blocking)
This should include offline_access to showcase getting a refresh token
| func handleLogin(w http.ResponseWriter, r *http.Request) { | ||
| state, err := generateState() | ||
| if err != nil { | ||
| http.Error(w, "Failed to generate state", http.StatusInternalServerError) | ||
| return | ||
| } | ||
|
|
||
| // Store state for CSRF validation | ||
| stateMu.Lock() | ||
| stateStore[state] = true | ||
| stateMu.Unlock() | ||
|
|
||
| url := oauthConfig.AuthCodeURL(state) | ||
| http.Redirect(w, r, url, http.StatusTemporaryRedirect) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4/5 (serious issue: blocking)
Have we validated this code works? We're OAuth 2.1 so state is optional and not even recommended but PKCE is required.
That we're generating a state suggests we might be not generating a PKCE challenge.
- Go: Use correct Search.Query() with components.SearchRequest, add PKCE with oauth2.GenerateVerifier/S256ChallengeOption/VerifierOption - Java: Add Spring Security PKCE config, use correct search().query() API - Python: Add PKCE via code_challenge_method='S256', use models.SearchRequest - TypeScript: Use correct search.query() API (not search.search()) All examples now use real SDK APIs verified from GitHub READMEs and include proper PKCE implementation for secure OAuth flows. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Summary
Test plan
pnpm build🤖 Generated with Claude Code