#Auth is null: Cannot read property 'sendCustomChallengeAnswer' of null

1 messages · Page 1 of 1 (latest)

neat delta
#

LOG Cannot read property 'sendCustomChallengeAnswer' of null

import { Amplify } from "aws-amplify";

Amplify.configure({
  Auth: {
    identityPoolId: ,
    region: ,
    userPoolId:,
    userPoolWebClientId: ,
    mandatorySignIn: true,
    signUpVerificationMethod: "code",
    authenticationFlowType: "CUSTOM_AUTH"
  },
import { Auth } from "aws-amplify";

async function confirmOTP({ otp }): Promise<boolean> {
    console.log(Auth);  // Outputs a dictionary
    const outcome = Auth.sendCustomChallengeAnswer(session, otp)

Why can I not run Auth.sendCustomChallengeAnswer?

charred sparrow
#

HI @neat delta are you still facing this issue? If so, are you able to call other auth methods, for ex Auth.currentAuthenticatedUser() ?

neat delta
#

Hi @charred sparrow , still facing the issue. currentAuthenticatedUser() works. Auth.currentAuthenticatedUser() works. It sendCustomChallengeAnswer was working for a brief moment just now but stopped again. Can't tell why exactly. Could it be related to the session somehow? No code was changed. I ran bun update, then it was working, then I reloaded the app in the android simulator and it stopped working again. Haven't figured out how to reproduce it.

"amazon-cognito-identity-js": "^6.3.6",
"aws-amplify": "^5.3.11",
neat delta
#

Hmmm, I think I needed to put an await in the async function that runs Auth.signIn so it's await Auth.signIn.

charred sparrow
#

The error message is what is interesting to me, that Auth is null - im assuming that you have imported Auth from aws-amplify in the same file you are calling the sendCustomChallengeAnswer()?

Also most of the Auth methods return promises so you I do recommend awaiting them

neat delta
#

Yeah, imported in the same file from aws-amplify.

#

No other function, variable, etc are called Auth either. I can print out Auth and it shows the config from my Amplify.configuire({Auth: {...})

charred sparrow
#

what version of aws-amplify are you using? and is this on a web app/mobile?

neat delta
#

@charred sparrow apologies for the late message. This is on mobile.

"@aws-amplify/datastore-storage-adapter": "^2.0.48",
"amazon-cognito-identity-js": "^6.3.6",
"aws-amplify": "^5.3.11",