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

@geniux/google-drive-picker-core

v1.0.0

Published

A lightweight, **framework-agnostic** core package for integrating Google Drive Picker and Google Identity Services.

Downloads

962

Readme

@geniux/google-drive-picker-core

A lightweight, framework-agnostic core package for integrating Google Drive Picker and Google Identity Services.

This package provides foundational functionality designed to support integrations with any framework, such as React, Vue, or others.


Use in Framework-Specific Integrations

This core package is designed to support framework-specific packages, such as @geniux/google-drive-picker-react, which provides a ready-to-use implementation for React applications.

Developers using other frameworks can leverage this core package to build their own integrations or make a Pull Request here 😉


Features

  • OAuth Token Initialization via Google Identity Services.
  • Google Drive Picker Creation with customizable configurations (multi-select, file types, etc.).
  • Typed Interface for Google Picker and OAuth, including all necessary Google Drive API scopes.

Installation

To install @geniux/google-drive-picker-core, use your preferred package manager:

pnpm add @geniux/google-drive-picker-core

or

npm install @geniux/google-drive-picker-core

or

yarn add @geniux/google-drive-picker-core

Basic Usage

Initialize Google Identity for OAuth

To retrieve an OAuth token from Google Identity Services, use the initializeGoogleIdentityService function, providing your client ID and an array of scopes.

import { 
    type GoogleDriveScope, 
    initializeGoogleIdentityService 
} from '@geniux/google-drive-picker-core';

const clientId = 'YOUR_GOOGLE_CLIENT_ID';
const scopes: GoogleDriveScope[] = [
  'https://www.googleapis.com/auth/drive.file',
  'https://www.googleapis.com/auth/drive.readonly'
];

// Initialize Google Identity and get an OAuth token
initializeGoogleIdentityService({
  clientId,
  scopes,
  callback: (oauthToken: string) => {
    console.log('OAuth Token:', oauthToken);
    // Pass this token to createPicker or other Google APIs
  },
});

Create the Google Drive Picker

Using the OAuth token obtained, you can now create a Google Drive Picker instance to allow users to select files.

import { 
    type GoogleDrivePickerConfig, 
    type GoogleDriveFile, 
    createPicker
} from '@geniux/google-drive-picker-core';

const oauthToken = 'YOUR_OAUTH_TOKEN'; // Obtained from initializeGoogleIdentityService
const apiKey = 'YOUR_GOOGLE_API_KEY';

const config: GoogleDrivePickerConfig = {
  viewId: 'DOCS',
  allowMultiSelect: true,
};

// Callback function to handle selected files
const handleSelectedFiles = (files: GoogleDriveFile[]) => {
  console.log('Selected Files:', files);
};

// Create and open the picker
createPicker({
  oauthToken,
  apiKey,
  config,
  setSelectedFiles: handleSelectedFiles,
});

Types and Configuration Options

Refer to the package’s types folder for additional details and customization options.


License

MIT