@portal-hq/gdrive-storage v4.1.0-beta-3
Portal Google Drive backup storage
The @portal-hq/gdrive-storage package contains a storage adapter intended for use with the @portal-hq/core package.
This storage adapter allows end users to save backup MPC shares to their Google Drive.
Basic usage
Install the package in your React Native project.
yarn add @portal-hq/gdrive-storage # OR # npm install --save @portal-hq/gdrive-storageImport the package into the component where you initialize the Portal class
import Portal from '@portal-hq/core' import GoogleStorage from '@portal-hq/google-storage'- Register your storage adapter and initialize the Portal class
const storage = new GoogleStorage({ // Required for Android androidClientId: 'YOUR_ANDROID_CLIENT_ID', // Required for iOS iosClientId: 'YOUR_IOS_CLIENT_ID', // Optional folder: 'YOUR_CUSTOM_STORAGE_LOCATION', }) const portal = new Portal({ // ...your other config options backup: { gdrive: storage, }, })
Dependency linking
Because this package uses the @react-native-google-signin/google-signin and @robinbobin/react-native-google-drive-api-wrapper packages (which contain native modules) there is some additional linking required to make it work with your React Native project.
Explicitly install the @react-native-google-signin/google-signin and @robinbobin/react-native-google-drive-api-wrapper packages in your project.
yarn add @react-native-google-signin/google-signin
# OR #
npm install --save @react-native-google-signin/google-signinSetting up Google Drive Backups
For iOS
- Create a new project here
- Go here click
ENABLE APIS AND SERVICES. - Find
Google Driveand Enable it. - Click on
Create Credentialsand selectGoogle Drive APIandUser Datafor the type of data we are accessing. - Set up the OAuth Consent screen and add emails for testing
- Click on
Credentialson the left navigation bar and thenCREATE CREDENTIALS->OAuth Client ID - For
Application Typeselect iOS and enter the applications names. - Get your Bundle ID from the react-native / iOS project.
- Download your .plist and copy your
REVERSED_CLIENT_IDto the URL Scheme section of your info.plist in xcode. - Rename the downloaded plist file to
GoogleService-Info.plistand save to your/ios/directory. - Save your clientId for usage in the
PortalStorageProvider Add the below to your info.plist:
<key>CFBundleURLTypes</key> <array> <dict> <key>CFBundleTypeRole</key> <string>Editor</string> <key>CFBundleURLSchemes</key> <array> <string>REVERSE_CLIENT_ID</string> </array> </dict> </array>
For Android
To get Android working, you'll need to create 2 (two) OAuth Client IDs. One will be of type Android and the other of type Web
Create a new project here
Go here click
ENABLE APIS AND SERVICES.Find
Google Driveand Enable it.To get started, go to
Credentialsand clickCreate CredentialsSelect
OAuth Client IDSelect
Androidfrom the listFill in the form as instructed, with
Name,Package name, andSHA-1from your keystore. Note that when testing you'll want to use yourdebug.keystoreat/android/app/debug.keystore. However later on you'll need to switch this value when pushing it to the store. (See https://stackoverflow.com/questions/41194413/google-sign-in-for-android-release-vs-debug)After successfully creating your
AndroidOAuth Client ID, download the JSON:This will create a
google-service.jsonfile on your local machine.Move the
google-service.jsonfile into the/android/appdirectory.Go back to the
Credentialsscreen and repeat step 2.This time select
Web Application:All that you will need to input here is the
Name. Then after you clickCreate, copy the value fromYour Client ID.Paste this into where you implement
<PortalStorageProvider />like so:Now run a clean build / install, and you should be able to log into Google!
Once this is done, you can continue to develop your project like normal
7 months ago
12 months ago
8 months ago
11 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago