title: Problem whit NextAuth.js token length and Cognito
body: <p>I'm trying to implement authentication in my Next.js app using NextAuth.js and Cognito.
  Here's my problem: when the jwt callback is called I want to store in the session 3 tokens and other stuff but the token max length is 4096 bytes. How Can I implement this?
  Thanks in advance!</p>
  <pre><code>  providers: [
      Providers.Cognito({
        clientId: process.env.COGNITO_CLIENT_ID,
        domain: process.env.COGNITO_DOMAIN,
        idToken: true,
        scope: 'openid profile email aws.cognito.signin.user.admin',
      }),
    ],
    callbacks: {
      async jwt(token, user, account, profile) {
        // Initial sign in
        if (account &amp;&amp; user) {
          // Max 4096 bytes
          return {
            accessToken: account.accessToken,
            idToken: account.idToken, // Too long
            accessTokenExpires: Date.now() + account.expires_in! * 1000,
            refreshToken: account.refresh_token,
            user, // Too long
            profile, // Too long
          };
        }
  
        // Return previous token if the access token has not expired yet
        if (Date.now() &lt; (token.accessTokenExpires as number)) {
          return token;
        }
  
        // Access token has expired, try to update it
        return refreshAccessToken(token);
      },
      async session(session, token) {
        const sessionToken = session;
        sessionToken.accessToken = token.accessToken;
        sessionToken.idToken = token.idToken;
        sessionToken.profile = token.profile;
        return sessionToken;
      },
    },
  });
  </code></pre>