convex-auth-battlenet
v0.1.1
Published
Battle.net OAuth provider for Convex Auth
Maintainers
Readme
convex-auth-battlenet
Battle.net OAuth provider for Convex Auth.
Installation
npm install convex-auth-battlenet
# or
bun add convex-auth-battlenetSetup
1. Create a Battle.net Application
- Go to the Battle.net Developer Portal
- Create a new application
- Set the redirect URI to
https://your-convex-site.convex.site/api/auth/callback/battlenet - Copy the Client ID and Client Secret
2. Configure Environment Variables
Add to your Convex environment (via dashboard or CLI):
AUTH_BATTLENET_ID=your_client_id
AUTH_BATTLENET_SECRET=your_client_secret3. Add to Convex Auth
// convex/auth.ts
import { convexAuth } from "@convex-dev/auth/server";
import { BattleNet } from "convex-auth-battlenet";
export const { auth, signIn, signOut, store } = convexAuth({
providers: [BattleNet()],
});That's it! No custom schema or callbacks required.
Configuration Options
BattleNet({
// OAuth issuer URL (for China region use "https://oauth.battlenet.com.cn")
// Default: "https://oauth.battle.net"
issuer: "https://oauth.battlenet.com.cn",
// Override client credentials (optional, reads from env vars by default)
clientId: "your_client_id",
clientSecret: "your_client_secret",
});Frontend Usage
import { useAuthActions } from "@convex-dev/auth/react";
function LoginButton() {
const { signIn } = useAuthActions();
return (
<button onClick={() => signIn("battlenet")}>
Sign in with Battle.net
</button>
);
}User Profile
The provider maps the Battle.net profile to:
| Field | Source |
|-------|--------|
| id | sub (unique identifier) |
| name | battletag (e.g., "Player#1234") |
| email | Synthetic email ({sub}@battlenet.oauth) |
Note: Battle.net doesn't provide real email addresses. A synthetic email is generated for Convex Auth compatibility. This email cannot receive messages.
TypeScript
Full TypeScript support with exported types:
import type {
BattleNetConfig,
BattleNetProfile,
BattleNetIssuer,
} from "convex-auth-battlenet";License
MIT
