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

ngdrive

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ngdrive

  • 0.1.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

ngdrive

A simple ngdrive utitily to download files from gdrive folders recursively into local machine.

Google allows/supports accessing google drive files via API. Below steps are pre-requisites to do the same.

  1. First a gmail account is needed.
  2. An app must be created via console.developers.google.com eg: app-name: 'gdrive-syncher'. This can be 'Desktop App'.
  3. credentials.json file from above app must be placed in the config/ folder.
  4. 'Google Drive API' must be enabled for the above app via 'APIs & Services' -> 'Enable API & Services'.
  5. Above app must be registered with:
    • OAuth consent screen

      • App Info:

        • app name: gdrive-syncher
        • support email: email given in point 1 above
        • app logo optional
      • App Domain:

        • application home page: https://gmail.com
      • Authorized domains:

        • gmail.com
      • Developer contact information

        • email given in point 1 above
    • Scope

      • Google Drive API
    • Test users

      • email given in point 1 must be added as test user

Installation

Add this line to your application's Gemfile:

gem 'googledrive'

And then execute:

$ bundle

Or install it yourself as:

$ gem install googledrive

Usage

require 'googledrive'
gd = Ngdrive::GdriveUtil.new
gd.download_files

Above lines will pickup the files/folders present in the gdrive.folder_id value in settings.yml and download all files recursively into ./downloads folder along with their respective folder names.

  • Notes:
    • google drive maintains a session (via token) valid for a certain amount of time. This session is based on a token and will expire after the duration.

    • each time a request is made to google drive via API, it needs this token to allow google drive to continue accessing.

    • First time when 'Ngdrive::GdriveUtil.new' is run, the gem does below steps:

      • it prompts user with a url to copy and enter in the browser. This is OAuthentication request asking the user to allow the access to drive via gmail account. This consent is mandatory as per google rules and regulations.
      • When prompted with url on console, user has to enter the url in the browser, allow access, continue.
      • once confirmed, google returns a url with format similar to below:
      • 'https://....code=<<abce...xyz>>&aa=...' code received between << and >> is what is needed as initial token.
      • users have to copy this and enter in the console to allow gem to create config/token.yaml to keep the token for subsequent calls.
      • This token will expire after certain time, in which case, users have to do the url copy paste each time they need to access drive via API.
    • once token.yaml file is created, accessing and downloading googledrive files is as simple as running: gd.download_files

FAQs

Package last updated on 10 Jun 2022

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