Get OAuth URL
Get OAuth authorization URL for social login providers.
Endpoint
GET /api/v1/auth/oauth/{provider}/url
Headers
None required (public endpoint)
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
provider | string | Yes | OAuth provider: "github", "google", "apple", or "microsoft" |
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
state | string | No | Optional state parameter for CSRF protection |
Validations
- Provider must be one of: github, google, apple, microsoft
- State parameter validation (if provided)
Response
Success (200)
{
"success": true,
"data": {
"oauth_url": "https://github.com/login/oauth/authorize?client_id=...&state=...",
"provider": "github",
"state": "csrf_state_token"
},
"message": "GitHub OAuth URL generated successfully"
}
Error Codes
| Status | Code | Description |
|---|---|---|
| 400 | INVALID_PROVIDER | Invalid provider name |
Data Flow
-
Provider Validation
- Verify provider is supported
- Return error if invalid
-
URL Generation
- Get OAuth client credentials
- Build authorization URL
- Include redirect_uri
- Include state parameter (CSRF protection)
- Include scopes required
-
State Generation (if not provided)
- Generate random state token
- Store in session/cache for verification
-
Response
- Return complete OAuth URL
- Include provider and state
Features
- Generates OAuth authorization URL for GitHub, Google, Apple, or Microsoft
- Includes CSRF protection via state parameter
- Returns URL for frontend redirect
- Supports all major OAuth providers
Supported Providers
- GitHub - GitHub OAuth
- Google - Google OAuth
- Apple - Apple Sign In
- Microsoft - Microsoft Azure AD
Example
curl -X GET "https://api.rivergen.com/api/v1/auth/oauth/github/url?state=csrf_token_123"
Next Steps
- Redirect user to returned
oauth_url - User authorizes on provider
- Provider redirects to callback URL
- Use OAuth Callback or Social Login
Related Endpoints
- Social Login - Complete social login
- OAuth Callback - Handle provider callback