Hi everyone, I am trying to implement 'Sign-in with Apple' to my website using nextauth verion 4.24.5 on next.js version 14.2.7. I set up the Apple ID and generated the Apple secret. The Apple ID is set to the service ID. Whenever I try and sign in on the site using Apple, (after submitting my username and password on the redirected appleid.com page), nextauth returns this error:
[next-auth][error][OAUTH_CALLBACK_ERROR]
https://next-auth.js.org/errors#oauth_callback_error id_token not present in TokenSet {
error: TypeError: id_token not present in TokenSet
{
name: 'OAuthCallbackError',
code: undefined
},
providerId: 'apple',
message: 'id_token not present in TokenSet'
}
This occurs even after specifying openid in the scope, setting the checks to pkce, setting the checks to state, setting idToken to true, and other changes to the config. I have used the AppleProvider from nextauth and my own custom provider and got the same result. The nextauth GoogleProvider works just fine so I know nextauth is set up properly. Do you know how I can fix this?
my apple nextauth apple provider config:
const customAppleProvider = {
id: "apple",
name: "Apple",
type: "oauth",
wellKnown: "https://appleid.apple.com/.well-known/openid-configuration",
authorization: {
params: {
scope: "name email openid",
response_mode: "form_post"
},
},
state: true,
checks: ["pkce"],
idToken: true,
clientId: process.env.APPLE_ID,
clientSecret: process.env.APPLE_SECRET,
profile(profile) {
return {
id: profile.sub,
name: profile.name,
email: profile.email,
image: null,
}
},
};
Hi @LearvoLearning,
Even if your implementation does work for other authorization or identity providers, there still may be issues with your configuration or integration for Sign in with Apple within NextAuth.js. However, since your post has no content related to Sign in with Apple's implementation or configuration directly, I cannot provide much insight. I'd recommend contacting the support channels for NextAuth directly.
Apple | NextAuth.js
https://next-auth.js.org/providers/apple
Cheers,
Paris X Pinkney | WWDR | DTS Engineer