Social App Management API Documentation
Overview
The Social App Management API allows you to programmatically create and manage OAuth social applications (providers) for your multi-tenant Django application. This API provides simple CRUD operations with tenant isolation and automatic configuration.
Base URL: /api/auth/social-apps/
Authentication:
- List: No authentication required (public endpoint for login pages)
- All other endpoints: JWT Bearer Token required
Permissions:
- List: Public (no authentication required)
- Retrieve: Any authenticated user
- Create/Update/Delete: Superusers or Organization owners only
Table of Contents
- List Social Apps
- Create Social App
- Get Social App Details
- Update Social App
- Delete Social App
- Common Providers Examples
- Error Codes
1. List Social Apps
Get a list of all social apps for the current tenant. This endpoint is public (no authentication required) to allow login pages to fetch available OAuth providers.
Endpoint: GET /api/auth/social-apps/
Authentication: Not required (public endpoint)
Query Parameters:
| Parameter | Type | Description |
|---|---|---|
search | string | Search by name, provider, client_id, or provider_id |
provider | string | Filter by provider (e.g., google, github, openid_connect) |
ordering | string | Order by field (e.g., name, -name, provider) |
page | integer | Page number for pagination (default: 1) |
page_size | integer | Number of results per page (default: 10, max: 100) |
Example Request:
- REST API
- Python
- JavaScript
# Public access - no token needed
curl -X GET "https://your-site.taruvi.cloud/api/auth/social-apps/"
# With filters
curl -X GET "https://your-site.taruvi.cloud/api/auth/social-apps/?provider=openid_connect"
Response (200 OK):
{
"success": true,
"message": "Social apps retrieved successfully",
"data": [
{
"id": 1,
"provider": "openid_connect",
"provider_id": "keycloak",
"name": "Keycloak SSO",
"provider_display": "OpenID Connect",
"is_configured": true,
"icon": "https://cdn.example.com/keycloak-icon.svg",
"auto_redirect": false
},
{
"id": 2,
"provider": "google",
"provider_id": "",
"name": "Google OAuth",
"provider_display": "Google",
"is_configured": true,
"icon": "mdi-google",
"auto_redirect": true
}
],
"total": 2,
"page": 1,
"page_size": 10,
"total_pages": 1
}
import requests
# Public access - no token needed
response = requests.get(
"https://your-site.taruvi.cloud/api/auth/social-apps/"
)
social_apps = response.json()
# With filters
response = requests.get(
"https://your-site.taruvi.cloud/api/auth/social-apps/",
params={"provider": "openid_connect"}
)
filtered_apps = response.json()
// Public access - no token needed
const response = await fetch(
"https://your-site.taruvi.cloud/api/auth/social-apps/"
);
const { data: socialApps } = await response.json();
// Use on login page to render provider buttons
socialApps.forEach(provider => {
if (provider.is_configured) {
createProviderButton({
name: provider.name,
icon: provider.icon,
provider: provider.provider,
autoRedirect: provider.auto_redirect
});
}
});
Custom Parameters (Flattened in List):
icon(string): Icon URL or identifier for the provider buttonauto_redirect(boolean): Whether to auto-redirect to this provider on login page
2. Create Social App
Create a new OAuth social application.
Endpoint: POST /api/auth/social-apps/
Authentication: Required (Superuser or Organization Owner)
Request Body:
| Field | Type | Required | Description |
|---|---|---|---|
provider | string | Yes | OAuth provider type (e.g., google, github, openid_connect) |
provider_id | string | Conditional | Required for OpenID Connect and SAML providers |
name | string | Yes | Display name for this OAuth configuration |
client_id | string | Yes | OAuth client ID from provider console |
secret | string | Yes | OAuth client secret (will be masked in responses) |
key | string | No | Additional key field (rarely used) |
settings | object | Conditional | Provider-specific settings (required for OpenID Connect). Can include icon and auto_redirect custom parameters. |
Custom Parameters in settings:
icon(string, optional): Icon URL or identifier for the provider button (e.g.,"https://cdn.example.com/icon.svg"or"mdi-google")auto_redirect(boolean, optional): Auto-redirect to this provider on login page (default:false)server_url(string, required for OpenID Connect): OIDC discovery URL
Example 1: Create OpenID Connect (Keycloak) with Custom Parameters
- REST API
- Python
- JavaScript
curl -X POST "https://your-site.taruvi.cloud/api/auth/social-apps/" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"provider": "openid_connect",
"provider_id": "keycloak",
"name": "Keycloak SSO",
"client_id": "taruvi",
"secret": "6GUvx3aEaFDhfreWTJm78Hwsip9LB3uR",
"settings": {
"server_url": "https://keycloakstag.eoxvantage.com/realms/taruvi/.well-known/openid-configuration",
"icon": "https://cdn.example.com/keycloak-icon.svg",
"auto_redirect": false
}
}'
Response (201 Created):
{
"success": true,
"message": "Social app created successfully",
"data": {
"id": 1,
"provider": "openid_connect",
"provider_id": "keycloak",
"name": "Keycloak SSO",
"client_id": "taruvi",
"secret": "6GUvx3aEaFDhfreWTJm78Hwsip9LB3uR",
"key": "",
"settings": {
"server_url": "https://keycloakstag.eoxvantage.com/realms/taruvi/.well-known/openid-configuration",
"icon": "https://cdn.example.com/keycloak-icon.svg",
"auto_redirect": false
},
"provider_display": "OpenID Connect",
"is_configured": true
}
}
import requests
response = requests.post(
"https://your-site.taruvi.cloud/api/auth/social-apps/",
headers={
"Authorization": "Bearer YOUR_JWT_TOKEN",
"Content-Type": "application/json"
},
json={
"provider": "openid_connect",
"provider_id": "keycloak",
"name": "Keycloak SSO",
"client_id": "taruvi",
"secret": "6GUvx3aEaFDhfreWTJm78Hwsip9LB3uR",
"settings": {
"server_url": "https://keycloakstag.eoxvantage.com/realms/taruvi/.well-known/openid-configuration",
"icon": "https://cdn.example.com/keycloak-icon.svg",
"auto_redirect": False
}
}
)
result = response.json()
const response = await fetch(
"https://your-site.taruvi.cloud/api/auth/social-apps/",
{
method: "POST",
headers: {
"Authorization": "Bearer YOUR_JWT_TOKEN",
"Content-Type": "application/json"
},
body: JSON.stringify({
provider: "openid_connect",
provider_id: "keycloak",
name: "Keycloak SSO",
client_id: "taruvi",
secret: "6GUvx3aEaFDhfreWTJm78Hwsip9LB3uR",
settings: {
server_url: "https://keycloakstag.eoxvantage.com/realms/taruvi/.well-known/openid-configuration",
icon: "https://cdn.example.com/keycloak-icon.svg",
auto_redirect: false
}
})
}
);
const result = await response.json();
Example 2: Create Google OAuth
- REST API
- Python
- JavaScript
curl -X POST "https://your-site.taruvi.cloud/api/auth/social-apps/" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"provider": "google",
"name": "Google OAuth",
"client_id": "123456789.apps.googleusercontent.com",
"secret": "GOCSPX-abc123xyz789"
}'
import requests
response = requests.post(
"https://your-site.taruvi.cloud/api/auth/social-apps/",
headers={
"Authorization": "Bearer YOUR_JWT_TOKEN",
"Content-Type": "application/json"
},
json={
"provider": "google",
"name": "Google OAuth",
"client_id": "123456789.apps.googleusercontent.com",
"secret": "GOCSPX-abc123xyz789"
}
)
result = response.json()
const response = await fetch(
"https://your-site.taruvi.cloud/api/auth/social-apps/",
{
method: "POST",
headers: {
"Authorization": "Bearer YOUR_JWT_TOKEN",
"Content-Type": "application/json"
},
body: JSON.stringify({
provider: "google",
name: "Google OAuth",
client_id: "123456789.apps.googleusercontent.com",
secret: "GOCSPX-abc123xyz789"
})
}
);
const result = await response.json();
Example 3: Create GitHub OAuth
- REST API
- Python
- JavaScript
curl -X POST "https://your-site.taruvi.cloud/api/auth/social-apps/" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"provider": "github",
"name": "GitHub OAuth",
"client_id": "Iv1.a1b2c3d4e5f6g7h8",
"secret": "1234567890abcdef1234567890abcdef12345678"
}'
import requests
response = requests.post(
"https://your-site.taruvi.cloud/api/auth/social-apps/",
headers={
"Authorization": "Bearer YOUR_JWT_TOKEN",
"Content-Type": "application/json"
},
json={
"provider": "github",
"name": "GitHub OAuth",
"client_id": "Iv1.a1b2c3d4e5f6g7h8",
"secret": "1234567890abcdef1234567890abcdef12345678"
}
)
result = response.json()
const response = await fetch(
"https://your-site.taruvi.cloud/api/auth/social-apps/",
{
method: "POST",
headers: {
"Authorization": "Bearer YOUR_JWT_TOKEN",
"Content-Type": "application/json"
},
body: JSON.stringify({
provider: "github",
name: "GitHub OAuth",
client_id: "Iv1.a1b2c3d4e5f6g7h8",
secret: "1234567890abcdef1234567890abcdef12345678"
})
}
);
const result = await response.json();
Validation Errors
Missing Required Field:
{
"client_id": ["This field is required."]
}
Invalid Provider:
{
"provider": ["Invalid provider 'invalid'. Available providers: google, github, openid_connect, ..."]
}
OpenID Connect Missing provider_id:
{
"provider_id": ["provider_id is required for OpenID Connect provider"]
}
OpenID Connect Missing server_url:
{
"settings": ["server_url is required in settings for OpenID Connect. Example: {\"server_url\": \"https://your-idp.com/realms/your-realm\"}"]
}
3. Get Social App Details
Retrieve details of a specific social app. Secrets are masked for security. Custom parameters (icon, auto_redirect) are kept nested inside settings in this endpoint.
Endpoint: GET /api/auth/social-apps/{id}/
Authentication: Required
- REST API
- Python
- JavaScript
curl -X GET "https://your-site.taruvi.cloud/api/auth/social-apps/1/" \
-H "Authorization: Bearer YOUR_JWT_TOKEN"
Response (200 OK):
{
"id": 1,
"provider": "openid_connect",
"provider_id": "keycloak",
"name": "Keycloak SSO",
"client_id": "taruvi",
"secret": "***HIDDEN***",
"key": "",
"settings": {
"server_url": "https://keycloakstag.eoxvantage.com/realms/taruvi/.well-known/openid-configuration",
"icon": "https://cdn.example.com/keycloak-icon.svg",
"auto_redirect": false
},
"provider_display": "OpenID Connect",
"is_configured": true
}
import requests
response = requests.get(
"https://your-site.taruvi.cloud/api/auth/social-apps/1/",
headers={"Authorization": "Bearer YOUR_JWT_TOKEN"}
)
social_app = response.json()
const response = await fetch(
"https://your-site.taruvi.cloud/api/auth/social-apps/1/",
{
headers: { "Authorization": "Bearer YOUR_JWT_TOKEN" }
}
);
const socialApp = await response.json();
Note:
- The
secretfield is always masked as***HIDDEN***in GET responses for security - Custom parameters (
icon,auto_redirect) remain nested insidesettings(not flattened like in the list endpoint)
4. Update Social App
Partially update an existing social app configuration. Only send the fields you want to change.
Endpoint: PATCH /api/auth/social-apps/{id}/
Authentication: Required (Superuser or Organization Owner)
Request Body: Any fields from Create (all optional)
Note: PATCH allows partial updates - only include fields you want to change. Missing fields will retain their current values.
Example 1: Update Only Name
- REST API
- Python
- JavaScript
curl -X PATCH "https://your-site.taruvi.cloud/api/auth/social-apps/1/" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Keycloak SSO (Updated)"
}'
import requests
response = requests.patch(
"https://your-site.taruvi.cloud/api/auth/social-apps/1/",
headers={
"Authorization": "Bearer YOUR_JWT_TOKEN",
"Content-Type": "application/json"
},
json={"name": "Keycloak SSO (Updated)"}
)
result = response.json()
const response = await fetch(
"https://your-site.taruvi.cloud/api/auth/social-apps/1/",
{
method: "PATCH",
headers: {
"Authorization": "Bearer YOUR_JWT_TOKEN",
"Content-Type": "application/json"
},
body: JSON.stringify({ name: "Keycloak SSO (Updated)" })
}
);
const result = await response.json();
Example 2: Rotate Secret Only
- REST API
- Python
- JavaScript
curl -X PATCH "https://your-site.taruvi.cloud/api/auth/social-apps/1/" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"secret": "NEW-SECRET-KEY-HERE"
}'
import requests
response = requests.patch(
"https://your-site.taruvi.cloud/api/auth/social-apps/1/",
headers={
"Authorization": "Bearer YOUR_JWT_TOKEN",
"Content-Type": "application/json"
},
json={"secret": "NEW-SECRET-KEY-HERE"}
)
result = response.json()
const response = await fetch(
"https://your-site.taruvi.cloud/api/auth/social-apps/1/",
{
method: "PATCH",
headers: {
"Authorization": "Bearer YOUR_JWT_TOKEN",
"Content-Type": "application/json"
},
body: JSON.stringify({ secret: "NEW-SECRET-KEY-HERE" })
}
);
const result = await response.json();
Example 3: Update Multiple Fields
- REST API
- Python
- JavaScript
curl -X PATCH "https://your-site.taruvi.cloud/api/auth/social-apps/1/" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Keycloak SSO (Production)",
"settings": {
"server_url": "https://keycloak-prod.company.com/realms/company/.well-known/openid-configuration"
}
}'
import requests
response = requests.patch(
"https://your-site.taruvi.cloud/api/auth/social-apps/1/",
headers={
"Authorization": "Bearer YOUR_JWT_TOKEN",
"Content-Type": "application/json"
},
json={
"name": "Keycloak SSO (Production)",
"settings": {
"server_url": "https://keycloak-prod.company.com/realms/company/.well-known/openid-configuration"
}
}
)
result = response.json()
const response = await fetch(
"https://your-site.taruvi.cloud/api/auth/social-apps/1/",
{
method: "PATCH",
headers: {
"Authorization": "Bearer YOUR_JWT_TOKEN",
"Content-Type": "application/json"
},
body: JSON.stringify({
name: "Keycloak SSO (Production)",
settings: {
server_url: "https://keycloak-prod.company.com/realms/company/.well-known/openid-configuration"
}
})
}
);
const result = await response.json();
Example 4: Update Custom Parameters (icon, auto_redirect)
- REST API
- Python
- JavaScript
curl -X PATCH "https://your-site.taruvi.cloud/api/auth/social-apps/1/" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"settings": {
"server_url": "https://keycloak.example.com/realms/company/.well-known/openid-configuration",
"icon": "mdi-key",
"auto_redirect": true
}
}'
Response (200 OK):
{
"success": true,
"message": "Social app updated successfully",
"data": {
"id": 1,
"provider": "openid_connect",
"provider_id": "keycloak",
"name": "Keycloak SSO",
"client_id": "taruvi",
"secret": "***HIDDEN***",
"key": "",
"settings": {
"server_url": "https://keycloak.example.com/realms/company/.well-known/openid-configuration",
"icon": "mdi-key",
"auto_redirect": true
},
"provider_display": "OpenID Connect",
"is_configured": true
}
}
import requests
response = requests.patch(
"https://your-site.taruvi.cloud/api/auth/social-apps/1/",
headers={
"Authorization": "Bearer YOUR_JWT_TOKEN",
"Content-Type": "application/json"
},
json={
"settings": {
"server_url": "https://keycloak.example.com/realms/company/.well-known/openid-configuration",
"icon": "mdi-key",
"auto_redirect": True
}
}
)
result = response.json()
const response = await fetch(
"https://your-site.taruvi.cloud/api/auth/social-apps/1/",
{
method: "PATCH",
headers: {
"Authorization": "Bearer YOUR_JWT_TOKEN",
"Content-Type": "application/json"
},
body: JSON.stringify({
settings: {
server_url: "https://keycloak.example.com/realms/company/.well-known/openid-configuration",
icon: "mdi-key",
auto_redirect: true
}
})
}
);
const result = await response.json();
Note:
- The secret is masked in PATCH responses
- Custom parameters are nested inside
settings - Only specified fields are updated; others retain current values
5. Delete Social App
Delete a social app. Protected if users are actively using it.
Endpoint: DELETE /api/auth/social-apps/{id}/
Authentication: Required (Superuser or Organization Owner)
- REST API
- Python
- JavaScript
curl -X DELETE "https://your-site.taruvi.cloud/api/auth/social-apps/1/" \
-H "Authorization: Bearer YOUR_JWT_TOKEN"
Success Response (200 OK):
{
"success": true,
"message": "Social app deleted successfully"
}
import requests
response = requests.delete(
"https://your-site.taruvi.cloud/api/auth/social-apps/1/",
headers={"Authorization": "Bearer YOUR_JWT_TOKEN"}
)
result = response.json()
const response = await fetch(
"https://your-site.taruvi.cloud/api/auth/social-apps/1/",
{
method: "DELETE",
headers: { "Authorization": "Bearer YOUR_JWT_TOKEN" }
}
);
const result = await response.json();
Error Response - Users Exist (400 Bad Request):
{
"success": false,
"message": "Cannot delete social app. 5 user(s) are currently using this provider.",
"suggestion": "Consider disabling the app instead or migrate users to another provider first.",
"active_users": 5
}
6. Common Providers Examples
Google OAuth 2.0
Prerequisites:
- Go to Google Cloud Console
- Create a project or select existing one
- Enable Google+ API
- Create OAuth 2.0 credentials
- Add authorized redirect URIs:
https://yourdomain.com/accounts/google/login/callback/
Create Request:
{
"provider": "google",
"name": "Google OAuth",
"client_id": "123456789.apps.googleusercontent.com",
"secret": "GOCSPX-your-client-secret"
}
GitHub OAuth
Prerequisites:
- Go to GitHub Developer Settings
- Create a new OAuth App
- Set authorization callback URL:
https://yourdomain.com/accounts/github/login/callback/
Create Request:
{
"provider": "github",
"name": "GitHub OAuth",
"client_id": "Iv1.your-client-id",
"secret": "your-client-secret-here"
}
Microsoft OAuth (Azure AD)
Prerequisites:
- Go to Azure Portal
- Navigate to Azure Active Directory > App registrations
- Create a new registration
- Add redirect URI:
https://yourdomain.com/accounts/microsoft/login/callback/ - Create a client secret
Create Request:
{
"provider": "microsoft",
"name": "Microsoft OAuth",
"client_id": "your-application-id",
"secret": "your-client-secret"
}
Keycloak (OpenID Connect)
Prerequisites:
- Access your Keycloak admin console
- Create a client in your realm
- Set Valid Redirect URIs:
https://yourdomain.com/accounts/keycloak-*/login/callback/ - Note your realm URL
Create Request:
{
"provider": "openid_connect",
"provider_id": "keycloak",
"name": "Keycloak SSO",
"client_id": "your-client-id",
"secret": "your-client-secret",
"settings": {
"server_url": "https://keycloak.company.com/realms/company/.well-known/openid-configuration"
}
}
Note: The server_url should point to the .well-known/openid-configuration endpoint.
Okta (OpenID Connect)
Prerequisites:
- Go to Okta Developer Console
- Create a new application (Web App)
- Add Sign-in redirect URI:
https://yourdomain.com/accounts/okta/login/callback/
Create Request:
{
"provider": "openid_connect",
"provider_id": "okta",
"name": "Okta SSO",
"client_id": "your-client-id",
"secret": "your-client-secret",
"settings": {
"server_url": "https://your-domain.okta.com/.well-known/openid-configuration"
}
}
Auth0 (OpenID Connect)
Prerequisites:
- Go to Auth0 Dashboard
- Create a new application (Regular Web Application)
- Add Allowed Callback URLs:
https://yourdomain.com/accounts/auth0/login/callback/
Create Request:
{
"provider": "openid_connect",
"provider_id": "auth0",
"name": "Auth0 SSO",
"client_id": "your-client-id",
"secret": "your-client-secret",
"settings": {
"server_url": "https://your-tenant.auth0.com/.well-known/openid-configuration"
}
}
7. Error Codes
| HTTP Code | Description |
|---|---|
| 200 | Success |
| 201 | Created successfully |
| 400 | Bad request - validation error or deletion blocked |
| 401 | Unauthorized - missing or invalid authentication |
| 403 | Forbidden - insufficient permissions |
| 404 | Not found - social app doesn't exist |
| 500 | Internal server error |
Common Error Responses
Authentication Missing:
{
"detail": "Authentication credentials were not provided."
}
Permission Denied:
{
"detail": "You do not have permission to perform this action."
}
Not Found:
{
"detail": "Not found."
}
8. Important Settings
Auto-Connect Existing Users
The platform is configured with SOCIALACCOUNT_AUTO_CONNECT = True, which means:
When a user logs in via OAuth (e.g., Keycloak):
- If a user with the same email already exists in the system
- The OAuth account will be automatically connected to that existing user
- The user will not be duplicated
- The user logs in with their existing account
This prevents duplicate accounts when users already exist in the system before enabling social login.
9. Integration with Allauth
After creating a social app via API, users can authenticate using the standard allauth endpoints:
Login Page
Visit: http://yourdomain.com/accounts/login/
The configured social login buttons will automatically appear on this page.
Programmatic Social Login (Headless)
Step 1: Get authorization URL
- REST API
- Python
- JavaScript
curl -X GET "https://your-site.taruvi.cloud/api/auth/{provider}/redirect/" \
-H "Authorization: Bearer YOUR_JWT_TOKEN"
import requests
response = requests.get(
"https://your-site.taruvi.cloud/api/auth/{provider}/redirect/",
headers={"Authorization": "Bearer YOUR_JWT_TOKEN"}
)
redirect_url = response.json()
const response = await fetch(
"https://your-site.taruvi.cloud/api/auth/{provider}/redirect/",
{
headers: { "Authorization": "Bearer YOUR_JWT_TOKEN" }
}
);
const redirectUrl = await response.json();
Step 2: Redirect user to OAuth provider
Step 3: Handle callback and get tokens
- REST API
- Python
- JavaScript
curl -X POST "https://your-site.taruvi.cloud/api/auth/{provider}/token/" \
-H "Content-Type: application/json" \
-d '{"code": "OAUTH_CALLBACK_CODE"}'
import requests
response = requests.post(
"https://your-site.taruvi.cloud/api/auth/{provider}/token/",
headers={"Content-Type": "application/json"},
json={"code": "OAUTH_CALLBACK_CODE"}
)
tokens = response.json()
const response = await fetch(
"https://your-site.taruvi.cloud/api/auth/{provider}/token/",
{
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ code: "OAUTH_CALLBACK_CODE" })
}
);
const tokens = await response.json();
10. Troubleshooting
Social app created but not showing on login page
Check:
- Ensure you're accessing the correct tenant domain
- Verify
SOCIALACCOUNT_USE_SITES = Falsein settings - Check admin interface:
http://yourdomain.com/admin/socialaccount/socialapp/ - Restart the web container:
docker-compose restart web
Authentication fails with "Invalid client"
Solution:
- Verify
client_idandsecretare correct - Check redirect URIs match in provider console
- For OpenID Connect, verify
server_urlis accessible
Users are being duplicated
Check:
- Ensure
SOCIALACCOUNT_AUTO_CONNECT = Truein settings - Verify email addresses match between systems
- Check that email is being provided by the OAuth provider
11. Quick Start Example
Complete workflow to set up Keycloak OAuth:
- REST API
- Python
- JavaScript
# 1. Get JWT token
TOKEN=$(curl -X POST "https://your-site.taruvi.cloud/api/auth/jwt/token/" \
-H "Content-Type: application/json" \
-d '{"username":"admin","password":"password"}' | jq -r '.access')
# 2. Create Keycloak social app
curl -X POST "https://your-site.taruvi.cloud/api/auth/social-apps/" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"provider": "openid_connect",
"provider_id": "keycloak",
"name": "Keycloak SSO",
"client_id": "taruvi",
"secret": "your-secret",
"settings": {
"server_url": "https://keycloak.example.com/realms/company/.well-known/openid-configuration"
}
}'
# 3. Verify it was created
curl -X GET "https://your-site.taruvi.cloud/api/auth/social-apps/" \
-H "Authorization: Bearer $TOKEN"
# 4. Test login
# Visit: https://your-site.taruvi.cloud/accounts/login/
# You should see "Login with OpenID Connect" button
import requests
BASE_URL = "https://your-site.taruvi.cloud"
# 1. Get JWT token
token_response = requests.post(
f"{BASE_URL}/api/auth/jwt/token/",
json={"username": "admin", "password": "password"}
)
token = token_response.json()["access"]
headers = {"Authorization": f"Bearer {token}"}
# 2. Create Keycloak social app
create_response = requests.post(
f"{BASE_URL}/api/auth/social-apps/",
headers={**headers, "Content-Type": "application/json"},
json={
"provider": "openid_connect",
"provider_id": "keycloak",
"name": "Keycloak SSO",
"client_id": "taruvi",
"secret": "your-secret",
"settings": {
"server_url": "https://keycloak.example.com/realms/company/.well-known/openid-configuration"
}
}
)
print(create_response.json())
# 3. Verify it was created
list_response = requests.get(
f"{BASE_URL}/api/auth/social-apps/",
headers=headers
)
print(list_response.json())
const BASE_URL = "https://your-site.taruvi.cloud";
// 1. Get JWT token
const tokenResponse = await fetch(`${BASE_URL}/api/auth/jwt/token/`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ username: "admin", password: "password" })
});
const { access: token } = await tokenResponse.json();
// 2. Create Keycloak social app
const createResponse = await fetch(`${BASE_URL}/api/auth/social-apps/`, {
method: "POST",
headers: {
"Authorization": `Bearer ${token}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
provider: "openid_connect",
provider_id: "keycloak",
name: "Keycloak SSO",
client_id: "taruvi",
secret: "your-secret",
settings: {
server_url: "https://keycloak.example.com/realms/company/.well-known/openid-configuration"
}
})
});
console.log(await createResponse.json());
// 3. Verify it was created
const listResponse = await fetch(`${BASE_URL}/api/auth/social-apps/`, {
headers: { "Authorization": `Bearer ${token}` }
});
console.log(await listResponse.json());
Support
For issues or questions:
- Check logs:
docker logs taruvi_web - Review admin interface:
/admin/socialaccount/socialapp/ - API documentation:
/api/docs/(Swagger UI) - ReDoc:
/api/redoc/
Last Updated: January 2025 API Version: 1.0.0 Django Version: 5.2.6 Allauth Version: 65.13.0