AWS Amplify Auth Giving UserUnAuthenticatedException When used with ssr:true

383 Views Asked by At

As per the AWS Amplify Official Document, since I want to use auth with SSR, I have configured Amplify using following code

import { Amplify } from 'aws-amplify'; import config from '../amplifyconfiguration.json';

Amplify.configure(config, {ssr: true});

But when I try to SignIn using below code

async function login() {
    try {
        console.log(email, password);
        const user = await signIn({ username: email, password: password });
        console.log(user);
        if (user.isSignedIn) {
            router.push('/admin');
        }
    } catch (error) {
        console.log('error signing in', error);
    }
}

it is giving Error

userunauthenticatedexception: User needs to be authenticated to call this API.AmplifyError AuthError assertAuthTokens (anonymous function)

Want to understand what is wrong in these steps

0

There are 0 best solutions below