Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vue-gpicker

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-gpicker

Vue Google Picker =================== Simple vue wrapper for [Google Picker API](https://developers.google.com/picker/docs/)

  • 0.1.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
29
decreased by-59.72%
Maintainers
1
Weekly downloads
 
Created
Source

Vue Google Picker

Simple vue wrapper for Google Picker API

Based on react-google-picker

Installation

npm install vue-gpicker

Usage

<VueGPicker :clientId="'your-client-id'"
            :developerKey="'your-developer-key'"
            :scope="['https://www.googleapis.com/auth/drive.readonly']"
            :onChange="(data) => console.log('on change:', data)"
            :multiselect="true"
            :navHidden="false"
            :authImmediate="false"
            :upload="true"
            :mimeTypes="['image/png', 'image/jpeg', 'image/jpg']"
            :viewId="'DOCS'">
   <MyCustomButton />
</VueGPicker>

Authentication token

You might want to get the Oauth token in order to use it later, for example in order to download the selected file. You can do so by using onAuthenticate:

<VueGPicker :clientId="'your-client-id'"
            :developerKey="'your-developer-key'"
            :scope="['https://www.googleapis.com/auth/drive.readonly']"
            :onChange="(data) => console.log('on change:', data)"
            :onAuthenticate="(token) => console.log('oauth token:', token)"
            :multiselect="true"
            :navHidden="false"
            :authImmediate="false"
            :upload="true"
            :mimeTypes="['image/png', 'image/jpeg', 'image/jpg']"
            :viewId="'DOCS'">
   <MyCustomButton />
</VueGPicker>

Custom build method

You can override the default build function by passing your custom function which receives two arguments:

  • google: a reference to the window.google object.
  • access_token: which you will need to pass to setOAuthToken method.
<VueGPicker :clientId="CLIENT_ID"
            :developerKey="DEVELOPER_KEY"
            :scope="SCOPE"
            :onChange="(data) => console.log('on change:', data)"
            :multiselect="true"
            :navHidden="false"
            :authImmediate="false"
            :upload="true"
            :viewId='FOLDERS'
            :createPicker="(google, oauthToken) => {
                const googleViewId = google.picker.ViewId.FOLDERS;
                const docsView = new google.picker.DocsView(googleViewId)
                    .setIncludeFolders(true)
                    .setMimeTypes('application/vnd.google-apps.folder')
                    .setSelectFolderEnabled(true);

                const picker = new window.google.picker.PickerBuilder()
                    .addView(docsView)
                    .setOAuthToken(oauthToken)
                    .setDeveloperKey(DEVELOPER_KEY)
                    .setCallback(()=>{
                        console.log('Custom picker is ready!');
                    });

                picker.build().setVisible(true);
            }"
        >
        <span>Click</span>
        <div className="google"></div>
</VueGPicker>

This example creates a picker which shows folders and you can select folders.

Demo

npm install
npm start
open http://localhost:8080

Don't forget to add new origins at console.developers.google.com

Keywords

FAQs

Package last updated on 06 Aug 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc