Quick Start: Connect Client App
Connect your application to Optare ID using standard OAuth 2.0 / OpenID Connect.
Your Domain
https://id.optare.oneStep 1: Create OAuth Client
- Go to Portal › OAuth Clients.
- Click Create OAuth Client.
- Enter details:
- Name:
My App - Redirect URIs:
http://localhost:3000/api/auth/callback/optare(for Next.js) - Allowed Origins:
http://localhost:3000
- Name:
- Copy the Client ID and Client Secret.
Step 2: Choose Your Framework
Next.js (Recommended)
Using next-auth (Auth.js) is the easiest way to integrate.
1. Install
npm install next-auth2. Environment (.env.local)
OPTARE_CLIENT_ID=oauth_xxxxxxxxxxxxxxxx
OPTARE_CLIENT_SECRET=secret_xxxxxxxxxxxxxxxx
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=your-random-secret-key3. Configure (app/api/auth/[...nextauth]/route.ts)
import NextAuth from "next-auth";
export const handler = NextAuth({
providers: [
{
id: "optare",
name: "Optare",
type: "oauth",
wellKnown: "https://id.optare.one/.well-known/openid-configuration",
clientId: process.env.OPTARE_CLIENT_ID,
clientSecret: process.env.OPTARE_CLIENT_SECRET,
authorization: { params: { scope: "openid email profile" } },
checks: ["pkce", "state"],
profile(profile) {
return {
id: profile.sub,
name: profile.name,
email: profile.email,
image: profile.picture,
};
},
},
],
});
export { handler as GET, handler as POST };