Setup OAuth Providers

Enable Google, GitHub, or Discord login for your project's users in minutes.

1. Get Provider Credentials

Google

  1. Go to Google Cloud Console
  2. Create OAuth 2.0 Client ID
  3. Set redirect URI
  4. Copy Client ID & Secret

GitHub

  1. Go to GitHub Developer Settings
  2. Create new OAuth App
  3. Set callback URL
  4. Copy Client ID & Secret

Discord

  1. Go to Discord Developer Portal
  2. Create new Application
  3. Add redirect URI under OAuth2
  4. 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/callback

3. 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}/authorize
2User 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>
  );
}