Amplify-js: Cannot read property 'clientMetadata' of undefined

Created on 22 Jan 2020  路  7Comments  路  Source: aws-amplify/amplify-js

Describe the bug
Using amplify CLI I have created a simple sign in following the docs.
Calling Auth.signIn(username, password) throws following error:

TypeError: Cannot read property 'clientMetadata' of undefined
    at AuthClass.signIn (Auth.js:344)
    at submitLoginForm (app.js:60)
    at HTMLFormElement.onSubmitLoginForm (app.js:37)
submitLoginForm @ app.js:90
onSubmitLoginForm @ app.js:37

To Reproduce

Sample code (crtl/amplify-demo)

Expected behavior
No error

to-be-reproduced

Most helpful comment

I found the solution...

Earlier we were passing aws config using below line:
Amplify.configure(awsConfig)

But according to new version of aws-amplify we need to pass the same configuration ion Auth as well...

So just add the same configuration for Auth as below...
Auth.configure(awsConfig)

try it.. it will work.

All 7 comments

It was my fault.
I havent called Amplify.configure() correctly.

Hello There,

Since yesterday, we are receiving same error in our application...

We did not change anything in code.. It was working fine till yesterday...

But later we checked and many of the aws-* libraries updated... So may be that can be the issue... But still looking into the issue from my end.

So please help me if anyone has solution.

Thanks :)

We are also facing same issue. yesterday our Angular build was working fine, but since from today morning its not working and we are facing same error.
`main-es2015.3a412c60369097305fdc.js:1 [ERROR] 31:57.727 AuthError -
Error: Amplify has not been configured correctly.
This error is typically caused by one of the following scenarios:

        1. Make sure you're passing the awsconfig object to Amplify.configure() in your app's entry point
            See https://aws-amplify.github.io/docs/js/authentication#configure-your-app for more information

        2. There might be multiple conflicting versions of aws-amplify or amplify packages in your node_modules.
            Try deleting your node_modules folder and reinstalling the dependencies with `yarn install``

TypeError: Cannot read property 'clientMetadata' of undefined

I found the solution...

Earlier we were passing aws config using below line:
Amplify.configure(awsConfig)

But according to new version of aws-amplify we need to pass the same configuration ion Auth as well...

So just add the same configuration for Auth as below...
Auth.configure(awsConfig)

try it.. it will work.

Thanks
Now its working fine .

So just add the same configuration for Auth as below...
Auth.configure(awsConfig)

Thanks @atulBriqsdata
Adding Auth.configure(awsconfig) alongside Amplify.configure(awsconfig) fixed it for us.

if you dont understand where location Auth. please add this code.
import Amplify, { Auth } from 'aws-amplify';

Was this page helpful?
0 / 5 - 0 ratings