Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/wrathchaos/react-native-social-auth-helper
- Owner: WrathChaos
- Created: 2022-04-22T20:16:22.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-10-10T21:26:45.000Z (about 1 month ago)
- Last Synced: 2024-10-25T16:58:49.565Z (21 days ago)
- Topics: app, apple, application, auth, authentitcation, facebook, freakycoder, google, login, mobile, react, react-native, social-login, software
- Language: Java
- Homepage: https://freakycoder.com
- Size: 1.46 MB
- Stars: 8
- Watchers: 4
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[![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.