This package has been deprecated

Author message:

This package is no longer supported.

@8base/react-native-auth0-auth-client
TypeScript icon, indicating that this package has built-in type declarations

0.35.1 • Public • Published

8base react-native auth0 auth client

The 8base react-native auth0 auth client for the AuthProvider.

ReactNativeAuth0AuthClient

Table of Contents

ReactNativeAuth0AuthClient

Create an instance of the react-native auth0 auth client.

Parameters

  • workspaceId string Identifier of the 8base app workspace.
  • domain string Domain. See auth0 documentation.
  • clientId string Client id. See auth0 documentation.

Usage

...
import { AuthContext, AuthProvider, type AuthContextProps } from '@8base/auth';
import { ReactNativeAuth0AuthClient } form '@8base/react-native-auth0-auth-client';

  const authClient = new ReactNativeAuth0AuthClient({
    domain: 'domain',
    clientId: 'client-id',
    workspaceId: 'workspace-id',
  });

  ...

  const renderAuth = (auth) => {
    const authorize = async () => {
      const authData = await auth.authorize();

      await auth.setAuthState({
        token: authData.idToken,
        email: authData.email,
      });
    };

    const logout = async () => {
      await auth.purgeAuthState();
    };

    if (auth.isAuthorized) {
      return (
        <View>
          <Text>Hi ${auth.authState.email} !</Text>
          <Button title='Logout' onPress={ logout } />
        </View>
      );
    }

    return (
      <View>
        <Button title='Authorize with auth0' onPress={ authorize } />
      </View>
    );
  };

  ...

  <AuthProvider authClient={ authClient }>
    ...
      <AuthContext.Consumer>
        { renderAuth }
      </AuthContext.Consumer>
    ...  
  </AuthProvider>

Dependents (0)

Package Sidebar

Install

npm i @8base/react-native-auth0-auth-client

Weekly Downloads

5

Version

0.35.1

License

MIT

Unpacked Size

17.2 kB

Total Files

15

Last publish

Collaborators

  • dav1nx1
  • jorge.osorio
  • 8base-bot