Apple authentificaiton

Hey i'm kinda new to better auth and i did create pretty easily auth with credentials and google, i have a apple developper license and i'm looking to create an authentication but i'm stuck :

i'm using nextjs on this app :

i created the app id xx.xx.appname with Sign In with Apple but no setup
i also did the service xx.xx.appname.client with domain : domain.net and return url : https://domain.net/api/auth/callback/apple

and i'm stuck here at the keys part and the setup in the .env :
i created a key with Sign in with Apple the right app id and i downloaded the .p8
how do i create the jwt, do i create a script on the server or and is the jwt the client secret like we say in the documentation ?

but i don't know what to do now what is the APPLE_CLIENT_ID and the APPLE_CLIENT_SECRET for the .env
Solution
you will need to generate the apple client secret yourself, you can set up a script to do just that eg
const jwt = require("jsonwebtoken");

 // Create JWT
  const token = jwt.sign({}, privateKey, {
    algorithm: "ES256",
    expiresIn: "180d", // Maximum allowed by Apple is 6 months
    audience: "https://appleid.apple.com",
    issuer: env.teamId,
    subject: env.clientId,
    keyid: env.keyId,
  });

privateKey is the p8 file's contents and token is your apple client secret
Was this page helpful?