Skip to content

Conversation

subhankarmaiti
Copy link
Contributor

Changes

This PR introduces a new public method, saveCredentials, to the useAuth0 hook.

This change is important because it enables developers to integrate the react-native-auth0 SDK with custom authentication flows. Previously, the SDK could only manage credentials obtained through its own authorize method. With saveCredentials, developers can now obtain credentials from an external source (e.g., a custom backend API that performs authentication) and inject them into the SDK's secure storage. Once saved, the SDK can manage the user's session, including refreshing tokens, as if the login had occurred through the standard flow.

  • Added: saveCredentials(credentials: Credentials): Promise<void> to the Auth0ContextInterface.
  • Added: The saveCredentials function is now implemented in the Auth0Provider and exposed through the useAuth0 hook.

References

Fixes #950

Testing

This change is tested with a new suite of unit tests in Auth0Provider.spec.tsx. The tests cover the following scenarios:

  • A successful call to saveCredentials correctly invokes the underlying credentialsManager.saveCredentials method with the provided credentials.

  • An error thrown by the credentialsManager is caught, dispatched to the Auth0 state, and re-thrown for the caller to handle.

  • The method correctly handles both complete and minimal Credentials objects (e.g., without a refreshToken).

  • This change adds unit test coverage

  • This change has been tested on the latest version of the platform/language or why not

@subhankarmaiti subhankarmaiti requested a review from a team as a code owner August 28, 2025 07:21
@subhankarmaiti subhankarmaiti merged commit 81ad6cf into master Aug 28, 2025
3 checks passed
@subhankarmaiti subhankarmaiti deleted the SDK-6564-expose-missing-method branch August 28, 2025 08:43
NandanPrabhu added a commit that referenced this pull request Sep 29, 2025
* master:
  feat: add Claude Code PR Review workflow for enhanced pull request an… (#1317)
  feat: enhance Auth0Provider with platform-specific initialization and error handling (#1313)
  feat(web): Simplify Setup, Add Session Check & Fix Missing Refresh Token (#1303)
  Fix clearSession operation order to prevent premature user state clearing (#1309)
  Release v5.0.0-beta.6 (#1306)
  fix: concurrent credential storage errors by preventing unnecessary state updates (#1302)
  chore(deps): bump actions/checkout from 4 to 5 (#1272)
  chore(deps): bump actions/download-artifact from 4 to 5 (#1294)
  chore(deps): bump codecov/codecov-action from 5.5.0 to 5.5.1 (#1296)
  fix(docs): added back the docs folder (#1291)
  Release v5.0.0-beta.5 (#1290)
  fix(docs): organize exports into namespaces for better typedocs (#1269)
  fix: add missing clearSession native options (#1289)
  fix(android): add pathPrefix to Android manifest for proper App Links functionality (#1288)
  feat: add organization parameter support to resetPassword API (#1286)
  feat(auth): add `saveCredentials` method to `useAuth0` hook (#1285)
  feat: unify and improve error handling across platforms (#1261)
  chore(deps): bump codecov/codecov-action from 5.4.3 to 5.5.0 (#1279)
@subhankarmaiti subhankarmaiti mentioned this pull request Oct 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Get access to Auth0 instance from Auth0Provider

2 participants