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 ```typescript const jwt = require("jsonwebtoken"); // Create JWT...
Jump to solution
4 Replies
Solution
saze
saze3w ago
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,
});
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
ernicani
ernicaniOP3w ago
thank you very much
ernicani
ernicaniOP3w ago
i did everything put the APPLE_CLIENT_ID and APPLE_CLIENT_SECRET i did the script with APPLE_KEY_ID APPLE_PRIVATE_KEY APPLE_TEAM_ID APPLE_CLIENT_ID that i'm not gonna share for obvious reasons but i still got
No description
ernicani
ernicaniOP3w ago
ok i stfu i find why in the service i did not put the Domains and Subdomains ok no i don't understand should i put xx.company.project xx.company xx.company.project.client as apple client id on the .env

Did you find this page helpful?