Loading...
Loading...
Add NodeOps PKCE OAuth authentication to a Next.js app. Trigger when the user wants to set up NodeOps login, integrate NodeOps OAuth, add @nodeops-createos/integration-oauth, or connect a Next.js project to NodeOps identity/SSO. Also trigger on "add NodeOps auth", "setup NodeOps authentication", or "add NodeOps login".
npx skill4agent add nodeops-app/skills nodeops-authapp/pages/package.jsonnext@nodeops-createos/integration-oauthpackage.jsonapp/api/auth/[...nodeops]/route.ts.jsAuthProvider@nodeops-createos/integration-oauthapp/callback/page.tsx.jsx.env.exampleNODEOPS_package.jsonpnpm-lock.yamlyarn.locktsconfig.json.ts.tsx.js.jsxapp/pages/nextnpm install @nodeops-createos/integration-oauthpnpm add @nodeops-createos/integration-oauthyarn add @nodeops-createos/integration-oauthapp/api/auth/[...nodeops]/route.ts.jsexport { GET, POST } from '@nodeops-createos/integration-oauth/server';app/layout.tsxapp/layout.jsxapp/layout.jsapp/layout.tsimport { AuthProvider } from '@nodeops-createos/integration-oauth';{children}<body><AuthProvider><AuthProvider>{children}</AuthProvider>AuthProvider"use client"<AuthProvider>{children}<body>{children}redirectToapp/callback/page.tsx.jsx"use client";
import { useCallbackHandler } from "@nodeops-createos/integration-oauth";
export default function Callback() {
const { loading, error } = useCallbackHandler({ redirectTo: "/dashboard" });
if (loading) return (
<div style={{ display: "flex", justifyContent: "center", alignItems: "center", height: "100vh" }}>
<p>Signing in...</p>
</div>
);
if (error) return <p>Login failed: {error}</p>;
return null;
}.env.example# ── Client-side (exposed to browser via NEXT_PUBLIC_ prefix) ──────────────────
NEXT_PUBLIC_NODEOPS_AUTH_URL=https://id.nodeops.network/oauth2/auth
NEXT_PUBLIC_NODEOPS_CLIENT_ID=your_client_id_here
NEXT_PUBLIC_NODEOPS_REDIRECT_URI=http://localhost:3000/callback
NEXT_PUBLIC_NODEOPS_SCOPES=offline_access offline openid
# ── Server-side only (never sent to browser) ──────────────────────────────────
NODEOPS_CLIENT_SECRET=your_client_secret_here
NODEOPS_TOKEN_URL=https://id.nodeops.network/oauth2/token
NODEOPS_USERINFO_URL=https://autogen-v2-api.nodeops.network/v1/users/me.env.local.env.local.env.example.env.localNEXT_PUBLIC_NODEOPS_CLIENT_IDNODEOPS_CLIENT_SECRET.env.localNODEOPS_.gitignore.gitignore.env.local.env.gitignore.env
.env.localNEXT_PUBLIC_NODEOPS_CLIENT_IDNODEOPS_CLIENT_SECRETimport { useAuth, useUser } from '@nodeops-createos/integration-oauth';
const { isAuthenticated, login, logout, loading, authError } = useAuth();
const { user } = useUser();