Setup OAuth Providers
Enable Google, GitHub, or Discord login for your project's users in minutes.
1. Get Provider Credentials
- Go to Google Cloud Console
- Create OAuth 2.0 Client ID
- Set redirect URI
- Copy Client ID & Secret
GitHub
- Go to GitHub Developer Settings
- Create new OAuth App
- Set callback URL
- Copy Client ID & Secret
Discord
- Go to Discord Developer Portal
- Create new Application
- Add redirect URI under OAuth2
- Copy Client ID & Secret
2. Set Redirect URI
Use this callback URL in your provider's settings:
https://api.zmesh.in/projects/{project_id}/oauth/{provider}/callback
# Examples:
https://api.zmesh.in/projects/abc123/oauth/google/callback
https://api.zmesh.in/projects/abc123/oauth/github/callback
https://api.zmesh.in/projects/abc123/oauth/discord/callback3. Configure in zMesh
POST /projects/{project_id}/oauth/providers
{
"provider": "google",
"client_id": "xxx.apps.googleusercontent.com",
"client_secret": "GOCSPX-xxx",
"enabled": true
}4. Implement Login Flow
1Redirect user to
GET /oauth/{provider}/authorize2User authenticates with Google/GitHub/Discord
3Provider redirects back to your callback URL
4zMesh creates/links user account, returns JWT token
5. Frontend Integration
React / Next.jsJavaScript
function LoginButtons({ projectId }) {
const apiUrl = "https://api.zmesh.in";
return (
<div>
<a href={`${apiUrl}/projects/${projectId}/oauth/google/authorize`}>
Sign in with Google
</a>
<a href={`${apiUrl}/projects/${projectId}/oauth/github/authorize`}>
Sign in with GitHub
</a>
<a href={`${apiUrl}/projects/${projectId}/oauth/discord/authorize`}>
Sign in with Discord
</a>
</div>
);
}