| 77 | } |
| 78 | |
| 79 | func (*Service) extractClientCredentials(c *echo.Context, req *tokenRequest) (clientID, clientSecret string) { |
| 80 | // Try Basic auth first |
| 81 | authHeader := c.Request().Header.Get("Authorization") |
| 82 | if strings.HasPrefix(authHeader, "Basic ") { |
| 83 | decoded, err := base64.StdEncoding.DecodeString(strings.TrimPrefix(authHeader, "Basic ")) |
| 84 | if err == nil { |
| 85 | parts := strings.SplitN(string(decoded), ":", 2) |
| 86 | if len(parts) == 2 { |
| 87 | return parts[0], parts[1] |
| 88 | } |
| 89 | } |
| 90 | } |
| 91 | // Fall back to form params |
| 92 | return req.ClientID, req.ClientSecret |
| 93 | } |
| 94 | |
| 95 | func (s *Service) handleAuthorizationCodeGrant(c *echo.Context, client *store.OAuth2ClientMessage, req *tokenRequest) error { |
| 96 | ctx := c.Request().Context() |