1.1.15 • Published 1 year ago

react-native-thirdparty-logins v1.1.15

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

react-native-thirdparty-logins

Providing alternative ways to login. This will return a token, name and email of the user - use this to either create or validate users.

The tokens received from approval should then be used by the backend to verify the user from the backend

Installation

yarn add react-native-fbsdk-next
yarn add @invertase/react-native-apple-authentication
yarn add @react-native-google-signin/google-signin@latest
yarn add react-native-thirdparty-logins

Apple api setup

Remember to add "Sign in with apple" as a capability in the app. Email and name will only be returned on the first request - sequently request will only return a token.

Google api setup

Set the keys up in Google Cloud

its important to create android, web and ios as web i used for both android.

android

Local installation: From your project root

cd android && ./gradlew signingReport.

Scroll to the top of output, see the fingerprints. Debug fingerprint is used in dev, release fingerprint is used for release APK.

Add this to 'android/app/build.gradle

dependencies {
  implementation 'com.google.android.gms:play-services-auth:20.0.0'
}

Use the webapplication id for android when passing the key

ios

Add this google ios client id to plist

    <key>CFBundleURLTypes</key>
    <array>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>com.googleusercontent.apps.YOUR_GOOGLE_KEY</string>
        </array>
      </dict>
    </array>
    <key>CLIENT_ID</key>
    <string>YOUR_GOOGLE_KEY.apps.googleusercontent.com</string>
    <key>REVERSED_CLIENT_ID</key>
    <string>com.googleusercontent.apps.YOUR_GOOGLE_KEY</string>

Facebook api setup

Create an app in facebook business manager and collect the app id.

android

Follow this guide meta-guide

add these lines in AndroidManifest

 <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>
  <meta-data android:name="com.facebook.sdk.AutoInitEnabled" android:value="false"/>
  <meta-data android:name="com.facebook.sdk.ClientToken" android:value="CLIENT ID" />

add this in MainApplication.java

import com.facebook.FacebookSdk;



public void onCreate() {
    super.onCreate();
    FacebookSdk.sdkInitialize(getApplicationContext());
### ios
in ```info.plist``` add these values

CFBundleURLTypes CFBundleURLSchemes fb{FACEBOOK_APP_ID} FacebookAppID {FACEBOOK_APP_ID} FacebookDisplayName {APP_NAME} LSApplicationQueriesSchemes fbapi fb-messenger-share-api fbauth2 fbshareextension

add this to ```AppDelegate.m```

// AppDelegate.m #import <AuthenticationServices/AuthenticationServices.h> #import <SafariServices/SafariServices.h> #import <FBSDKCoreKit/FBSDKCoreKit-Swift.h>

//Inside didFinishLaunchingWithOptions, add the following [FBSDKApplicationDelegate sharedInstance application:application didFinishLaunchingWithOptions:launchOptions];

## Usage


```js
import LoginButtons from 'react-native-thirdparty-logins';

// ...

   const handleSucess = (data: {token: string | null, name: string | null, email: string | null}) => {
      //Returns object when authenticated
    };
    const handleError = (data: boolean) => {
      //data will return false if authentication failed or cancelled
    };

<LoginButtons
  onSuccess={handleSucess}
  onError={handleError}
  googleIOSClientId={GOOGLE_IOS_CLIENT_ID}
  googleAndroidClientId={GOOGLE_ANDROID_CLIENT_ID}
/>

Options

OptionValueRequiredDefault
onSuccess(userObject: {token: string, name: string, email: string}) => void;yes
onErrorfalseyes
theme'dark', 'light'no
googleEnabledbooleannotrue
iosEnabledbooleannotrue
facebookEnabledbooleannotrue
googleIOSClientIdstringyes
googleAndroidClientIdstringyes
iconOnlybooleannofalse
borderRadiusnumberno0
borderColorstringnonone
borderEnabledbooleannotrue

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library

1.1.15

1 year ago

1.1.14

1 year ago

1.1.13

1 year ago

1.1.12

1 year ago

1.1.11

1 year ago

1.1.10

1 year ago

1.1.9

1 year ago

1.1.8

1 year ago

1.1.7

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.12

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.1.19

1 year ago

0.1.18

1 year ago

0.1.17

1 year ago

0.1.16

1 year ago

0.1.15

1 year ago

0.1.14

1 year ago

0.1.13

1 year ago

0.1.12

1 year ago

0.1.11

1 year ago

0.1.10

1 year ago

0.1.9

1 year ago

0.1.8

1 year ago

0.1.7

1 year ago

0.1.6

1 year ago

0.1.5

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago