I have a React Native v0.75.4 application built with the React Native CLI where I’m implementing the passwordRealm login method then saving credentials using the credentialsManager.
The passwordRealm call is successful and returns a credentials object, but when trying to save it using the credentialsManager saveCredentials method, it throws the following error:
[a0.credential_manager.invalid: Cannot read property 'hasValidAuth0Instance' of null]
The version of the react-native-auth0 SDK in package.json is:
"react-native-auth0": "^3.2.1"
The code in my application is below:
import Auth0 from 'react-native-auth0';
const auth0 = new Auth0({
domain: DOMAIN, // uses real value
clientId: CLIENT_ID, // uses real value
});
export const login = async (username: string, password: string) => {
try {
const credentials = await auth0.auth.passwordRealm({
username,
password,
realm: config.realm,
scope: config.scope,
});
await auth0.credentialsManager.saveCredentials(credentials); <- error
} catch (err) {
console.log(err);
}
};