Skip to main content

Auth.js integration

This quickstart guide covers the essential steps to start integrating Pangea AuthN in an Auth.js application.

Create an OAuth client

Create a new OAuth client as described in OAuth Server with the following parameters:

  • Grant Types: Authorization Code
  • Response Types: Code, Token
  • Allowed Redirect URIs: [origin]/api/auth/callback/pangea
  • Allowed Scopes: openid, profile, email
  • Default scopes: openid, profile, email

Note down the client ID (starts with "psa_") and client secret (starts with "pck_") for later.

Set up environment variables

# .env.local

PANGEA_AUTHN_CLIENT_ID=psa_000000
PANGEA_AUTHN_CLIENT_SECRET=pck_111111
PANGEA_AUTHN_HOSTED_LOGIN=https://pdn-222222.login.aws.us.pangea.cloud

Set up provider

// auth.ts

import NextAuth from "next-auth";

export const { handlers, signIn, signOut, auth } = NextAuth({
providers: [
// ...

{
id: "pangea",
name: "Pangea",
type: "oauth",
checks: ["state", "pkce"],

clientId: process.env.PANGEA_AUTHN_CLIENT_ID,
clientSecret: process.env.PANGEA_AUTHN_CLIENT_SECRET,

issuer: process.env.PANGEA_AUTHN_HOSTED_LOGIN,
wellKnown: `${process.env.PANGEA_AUTHN_HOSTED_LOGIN}/.well-known/oauth-authorization-server`,
authorization: `${process.env.PANGEA_AUTHN_HOSTED_LOGIN}/v1beta/oauth/authorize`,
token: `${process.env.PANGEA_AUTHN_HOSTED_LOGIN}/v1beta/oauth/token`,
userinfo: `${process.env.PANGEA_AUTHN_HOSTED_LOGIN}/v1beta/oauth/userinfo`,
},
],
});

Was this article helpful?

Contact us