Access denied in next auth on using callbacks
Unanswered
Somali posted this in #help-forum
SomaliOP
I apologize in advance if this is out of the scope of this discord.
I'm trying to store user details in my remote DB on login.
The problem is that if I use callbacks, then I get an ACCESS_DENIED error, if I remove callbacks, then I log in successfully.
I think the reason is that this data is undefined
accessTokenundefined
idToken:undefined
I'm trying to store user details in my remote DB on login.
The problem is that if I use callbacks, then I get an ACCESS_DENIED error, if I remove callbacks, then I log in successfully.
I think the reason is that this data is undefined
accessTokenundefined
idToken:undefined
export const authOptions = {
secret: process.env.NEXTAUTH_SECRET,
providers: [
GoogleProvider({
clientId: process.env.GOOGLE_CLIENT_ID,
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
}),
],
callbacks: {
async signIn({ user, account, profile }) {
if (account.provider === 'google') {
const { accessToken, idToken } = account;
console.log(
'\naccessToken' + accessToken + '\nidToken:' + idToken,
);
}
await ky
.post('https://next.rue-spots.de/api/login', {
body: JSON.stringify({
username: user.name,
email: user.email,
}),
})
.json()
.catch((err) => {
console.log(err);
});
},
},
};