Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/wrathchaos/react-native-social-auth-helper

React Native Social Auth Helper
https://github.com/wrathchaos/react-native-social-auth-helper

app apple application auth authentitcation facebook freakycoder google login mobile react react-native social-login software

Last synced: 13 days ago
JSON representation

React Native Social Auth Helper

Awesome Lists containing this project

README

        

React Native Social Auth Helper

[![npm version](https://img.shields.io/npm/v/react-native-social-auth-helper.svg?style=for-the-badge)](https://www.npmjs.com/package/react-native-social-auth-helper)
[![npm](https://img.shields.io/npm/dt/react-native-social-auth-helper.svg?style=for-the-badge)](https://www.npmjs.com/package/react-native-social-auth-helper)
![Platform - Android and iOS](https://img.shields.io/badge/platform-Android%20%7C%20iOS-blue.svg?style=for-the-badge)
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg?style=for-the-badge)](https://opensource.org/licenses/MIT)
[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg?style=for-the-badge)](https://github.com/prettier/prettier)

# Installation

Add the dependency:

```bash
npm i react-native-social-auth-helper
```

## Peer Dependencies

IMPORTANT! You need install them

```json
"@invertase/react-native-apple-authentication": ">= 2.4.0",
"@react-native-firebase/auth": ">= 21.0.0",
"@react-native-google-signin/google-signin": ">= 13.1.0",
"jwt-decode": ">= 4.0.0"
```

# Usage

## Import

```jsx
import { appleLogin, googleLogin } from "react-native-social-auth-helper";
```

## Google Login Usage

Do not forget to add your `webCientId` for Google configuration

```js
import { googleLogin } from "react-native-social-auth-helper";
import { GoogleSignin } from "@react-native-google-signin/google-signin";

GoogleSignin.configure({
offlineAccess: false,
webClientId: "your-web-client-id",
});

export const handleGoogleLogin = async () => {
await GoogleSignin.hasPlayServices();
const { authCredential, user } = await googleLogin();
const { id, email, name, photo } = user;
// Successfully login and fetched the google user data
// ... your logic
};
```

## Apple Login Usage

```js
import { appleLogin } from "react-native-social-auth-helper";

export const handleGoogleLogin = async () => {
const { appleAuthRequestResponse, userCredential } = await appleLogin();
const { email, fullName } = appleAuthRequestResponse;
const userData = {
id: userCredential.user.uid,
socialId: userCredential.user.providerData[0].uid,
socialType: SOCIAL_TYPE.APPLE,
email: email,
username: fullName?.givenName || null,
photo: userCredential.user.photoURL,
};
// Successfully login and fetched the apple user data
// ... your logic
};
```

## Future Plans

- [x] ~~LICENSE~~
- [ ] Write an article about the lib on Medium

## Author

FreakyCoder, [email protected]

## License

React Native Social Auth Helper is available under the MIT license. See the LICENSE file for more info.