1

I am using NextAuth for authentication using Cognito...

While adding storage (S3) I am getting this error enter image description here

I tried to go to Amplify Dashboard to add storage and there

enter image description here

so I manually tried to reuse my auth setup but same error

enter image description here

I need client secret for next-auth else I need to change my whole code structure...

enter image description here

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...

Arihant Jain
  • 817
  • 5
  • 17

1 Answers1

1

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

Sweety SK
  • 351
  • 1
  • 10