requireLocalAuthentication does not work when used via useAuth hook
Checklist
- [X] The issue can be reproduced in the react-native-auth0 sample app (or N/A).
- [X] I have looked into the Readme, Examples, and FAQ and have not found a suitable solution or answer.
- [X] I have looked into the API documentation and have not found a suitable solution or answer.
- [X] I have searched the issues and have not found a suitable solution or answer.
- [X] I have searched the Auth0 Community forums and have not found a suitable solution or answer.
- [X] I agree to the terms within the Auth0 Code of Conduct.
Description
The requireLocalAuthentication method exposed by the useAuth hook does not seem to work.
I have a hunch that it is because requireLocalAuthentication cannot be called after getCredentials, however a useEffect in Auth0Provider.tsx (line 79) calls getCredentials on mount. So this condition cannot be satisfied.
I can call the requireLocalAuthentication method exposed by the Auth0 directly as a workaround:
const configureLocalAuthentication = async () => {
const auth0 = new Auth0({
clientId,
domain,
})
try {
await auth0.credentialsManager.requireLocalAuthentication()
} catch (error) {
console.error(error)
}
}
export const AuthManager = ({ children }: PropsWithChildren) => {
useEffect(() => {
configureLocalAuthentication()
}, [])
return (
<Auth0Provider domain={domain} clientId={clientId} >
{children}
</Auth0Provider>
)
}
I have tested this on a real device.
Reproduction
- Setup the provider
- Down the tree, call the
requireLocalAuthenticationexposed by theuseAuthhook
useEffect(() => {
requireLocalAuthentication()
}, [requireLocalAuthentication])
- Nothing happens.
Additional context
No response
react-native-auth0 version
3.1.0
React Native version
0.72.10
Expo version
49.0.23
Platform
iOS
Platform version(s)
17.4
We are planning to address this issue along with other improvements in the next major release coming up this quarter. I'll share exact timelines by the mid of June.
any update on this @brth31 ?
Hi @botre , @thyming,
We've removed this API in v4 beta and made improvements around local authentication. Can you try it out once here and let us know how it goes ?
@botre @thyming Could we close this issue if it is resolved in v4 beta?
sounds good to me 👍🏻
On Fri, Nov 15, 2024 at 12:19 AM Bharath Natarajan @.***> wrote:
@botre https://github.com/botre @thyming https://github.com/thyming Could we close this issue if it is resolved in v4 beta?
— Reply to this email directly, view it on GitHub https://github.com/auth0/react-native-auth0/issues/880#issuecomment-2477981867, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQ5N2LKHTVTF36FB7DQYOL2AV76HAVCNFSM6AAAAABE6CVOJ2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINZXHE4DCOBWG4 . You are receiving this because you were mentioned.Message ID: @.***>
Closing this issue as it appears to be addressed in v4.0.0. Please update to the latest version and retest. Reopen this issue if you continue to experience the problem.