@bvndle/auth-react-native
v0.1.0
Published
Authenticate with Bvndle for React Native
Readme
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-nativeUsage
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:
| Param | Type | Description |
| :---------- | :--------------------------------- | :-------------------------------------------------------------------------- |
| env | dev | prod | Environment you want to use. |
| clientId | string | Client ID created after partner registration. |
| redirectUrl | string | App scheme or universal link. The redirect URL after sign in. |
| scope | email | fullname | profile | (optional) Determines the user data that is returned. Default is profile. |
Merging user account with Bvndle mergeAccount:
| Param | Type | Description |
| :---------- | :------- | :--------------------------------------------------- |
| userId | string | The registered user ID with the partner application. |
| redirectUrl | string | (optional) The redirect URL after merge account. |
