npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@portal-hq/gdrive-storage

v4.0.1

Published

Portal's Google Sign-in and Google Drive API injegration.

Downloads

834

Readme

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

  1. Install the package in your React Native project.

    yarn add @portal-hq/gdrive-storage
    
    # OR #
    
    npm install --save @portal-hq/gdrive-storage
  2. Import the package into the component where you initialize the Portal class

    import Portal from '@portal-hq/core'
    import GoogleStorage from '@portal-hq/google-storage'
  3. 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-signin

Setting up Google Drive Backups

For iOS

  1. Create a new project here

  2. Go here click ENABLE APIS AND SERVICES.

  3. Find Google Drive and Enable it.

  4. Click on Create Credentials and select Google Drive API and User Data for the type of data we are accessing.

  5. Set up the OAuth Consent screen and add emails for testing

  6. Click on Credentials on the left navigation bar and then CREATE CREDENTIALS -> OAuth Client ID

  7. For Application Type select iOS and enter the applications names.

  8. Get your Bundle ID from the react-native / iOS project.

  9. Download your .plist and copy your REVERSED_CLIENT_ID to the URL Scheme section of your info.plist in xcode.

  10. Rename the downloaded plist file to GoogleService-Info.plist and save to your /ios/ directory.

  11. Save your clientId for usage in the PortalStorageProvider

  12. 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

  1. Create a new project here

  2. Go here click ENABLE APIS AND SERVICES.

  3. Find Google Drive and Enable it.

  4. To get started, go to Credentials and click Create Credentials

  5. Select OAuth Client ID

  6. Select Android from the list

  7. Fill in the form as instructed, with Name, Package name, and SHA-1 from your keystore. Note that when testing you'll want to use your debug.keystore at /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)

  8. After successfully creating your Android OAuth Client ID, download the JSON:

    This will create a google-service.json file on your local machine.

  9. Move the google-service.json file into the /android/app directory.

  10. Go back to the Credentials screen and repeat step 2.

  11. This time select Web Application:

  1. All that you will need to input here is the Name. Then after you click Create, copy the value from Your Client ID.
  1. Paste this into where you implement <PortalStorageProvider /> like so:
  1. 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