0.1.0 • Published 6 months ago

@bvndle/auth-react-native v0.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
6 months ago

Bvndle Authentication Client

Authenticate with Bvndle for React Native. See Onboard Partners to use Bvndle Partner services.

Quick start

Install

npm install @bvndle/auth-react-native

# or

yarn add @bvndle/auth-react-native

Usage

import { initAuthClient } from "@bvndle/auth-react-native";

const AUTH_CLIENT = initAuthClient({
  env: "<ENV>",
  clientId: "<YOUR_CLIENT_ID>",
  scope: "<SCOPE>",
  redirectUrl: "<REDIRECT_URL>",
});

const App = () => {
  const handleSignIn = () => {
    AUTH_CLIENT.signIn({
      onSuccess: (token) => {
        // Do something with the token
      },
      onError: (err) => {
        // Do something with the error
      },
    });
  };

  return <Pressable onPress={handleSignIn}>Sign in with Bvndle</Pressable>;
};

Merge user account with Bvndle

const handleMergeAccount = () => {
  AUTH_CLIENT.mergeAccount({
    userId: "<USER_ID>",
    redirectUrl: "<REDIRECT_URL>",
  });
};

<Pressable onPress={handleMergeAccount}>Merge Account</Pressable>;

Initializing Bvndle SSO Client initAuthClient:

ParamTypeDescription
envdev | prodEnvironment you want to use.
clientIdstringClient ID created after partner registration.
redirectUrlstringApp scheme or universal link. The redirect URL after sign in.
scopeemail | fullname | profile(optional) Determines the user data that is returned. Default is profile.

Merging user account with Bvndle mergeAccount:

ParamTypeDescription
userIdstringThe registered user ID with the partner application.
redirectUrlstring(optional) The redirect URL after merge account.