英文:
Next-Auth deployment to aws amplify in a NextJS application
问题
I am using NextAuth for authentication using Cognito...
While adding storage (S3) I am getting this error
I tried to go to Amplify Dashboard to add storage and there
so I manually tried to reuse my auth setup but same error
I need client secret for next-auth else I need to change my whole code structure...
英文:
I am using NextAuth for authentication using Cognito...
While adding storage (S3) I am getting this error
I tried to go to Amplify Dashboard to add storage and there
so I manually tried to reuse my auth setup but same error
I need client secret for next-auth else I need to change my whole code structure...
import NextAuth from "next-auth/next";
function CognitoProvider(options) {
return {
id: "cognito",
name: "Cognito",
type: "oauth",
wellKnown: `${options.issuer}/.well-known/openid-configuration`,
idToken: true,
profile(profile) {
return {
id: profile.sub,
name: profile.name,
email: profile.email,
image: profile.picture,
};
},
options,
};
}
export default NextAuth({
providers: [
CognitoProvider({
clientId: process.env.COGNITO_CLIENT_ID,
clientSecret: process.env.COGNITO_CLIENT_SECRET,
issuer: process.env.COGNITO_DOMAIN,
}),
],
secret: process.env.JWT_SECRET,
callbacks: {
jwt({ token, account, profile }) {
if (account) {
console.log("Account exists");
// modify token
token.role = profile["cognito:groups"];
token.id = profile.sub;
}
return token;
},
session({ session, token }) {
if (session.user) {
// modify session
session.user.roles = token.role;
session.user.id = token.id;
}
return session;
},
},
});
Any help will be appreciated...
答案1
得分: 1
这可能与Cognito的配置问题有关,我不确定,但我附上了一个YouTube链接,以便您可以参考并重新检查Cognito的配置。
链接以供参考
英文:
I think that must related to any configuration issue with cognito, I am not sure but i am attaching a youtube link so that you can refer and recheck your configuration of cognito
link to refer
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论