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

selfish-google-drive

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

selfish-google-drive - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

src/lib/scp.js

11

package.json
{
"name": "selfish-google-drive",
"version": "1.0.3",
"version": "1.0.4",
"description": "Google drive api for that access your own account",

@@ -15,5 +15,5 @@ "main": "src/index.js",

],
"repository" : {
"type" : "git",
"url" : "https://github.com/davidasync/selfish-google-drive"
"repository": {
"type": "git",
"url": "https://github.com/davidasync/selfish-google-drive"
},

@@ -24,3 +24,6 @@ "author": "davidasync",

"bluebird": "^3.5.1",
"file-type": "^7.6.0",
"lodash": "^4.17.5",
"read-chunk": "^2.1.0",
"request": "^2.83.0",
"superagent": "^3.8.2"

@@ -27,0 +30,0 @@ },

@@ -11,4 +11,14 @@ # selfish-google-drive

# Usage
##### 1. mkdir
If you use the api for the first time, it will generate `sgd-token.json` (recommended to add it to .gitignore). Everytime you use the api, It will read the json file instead of call the api again to get the token, it will call the google api again if the sgd-token.json expired (expired in 3600s) or invalid.
The sgd-token.json should be like this
```json
{
"access_token": "somestring",
"token_type": "Bearer",
"expires_in": 3600
}
```
To init the package you should provide credential like below from google.
```js

@@ -20,6 +30,16 @@ const credential = {

}
```
You can check how to generate the credential at [How do I authorise an app (web or installed) without user intervention?
](https://stackoverflow.com/questions/19766912/how-do-i-authorise-an-app-web-or-installed-without-user-intervention)
const sgd =require('selfish-google-drive')(credential);
##### 1. mkdir
Create folder at your google drive
```js
return sgd.mkdir('HADOKE1N').then(console.log)
return sgd.loadToken(true).then(console.log)
// Example return object
// { kind: 'drive#file',
// id: '1rKARa_6zPZPPp4s5_ruOaxZLX6p3aIaE',
// name: 'HADOKE1N',
// mimeType: 'application/vnd.google-apps.folder' }
```

@@ -9,2 +9,3 @@

const wget = require('./lib/wget');
const scp = require('./lib/scp');

@@ -19,2 +20,3 @@ const loadToken = require('../utils/loadToken');

wget,
scp,
};

@@ -48,4 +50,6 @@

.catch((response) => {
const responseStatus = response.status || response.statusCode;
// 401 can happened because access token already expired
if (response.status !== 401) {
if (responseStatus !== 401) {
return Bluebird.reject(response.message || response.error || response);

@@ -52,0 +56,0 @@ }

@@ -7,2 +7,3 @@ module.exports = {

wget: 'https://www.googleapis.com/drive/v3/files',
scp: 'https://www.googleapis.com/upload/drive/v3/files',
};
module.exports = {
'application/vnd.google-apps.audio': 'application/zip',
'application/vnd.google-apps.document': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'application/vnd.google-apps.drawing': 'image/png',
'application/vnd.google-apps.file': 'application/zip',
'application/vnd.google-apps.folder': 'application/zip',
'application/vnd.google-apps.form': 'application/zip',
'application/vnd.google-apps.fusiontable': 'application/zip',
'application/vnd.google-apps.map': 'application/zip',
'application/vnd.google-apps.photo': 'application/zip',
'application/vnd.google-apps.presentation': 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
'application/vnd.google-apps.script': 'application/zip',
'application/vnd.google-apps.site': 'application/zip',
'application/vnd.google-apps.spreadsheet': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'application/vnd.google-apps.drawing': 'image/png',
'application/vnd.google-apps.unknown': 'application/zip',
'application/vnd.google-apps.video': 'application/zip',
'application/vnd.google-apps.drive-sdk': 'application/zip',
};

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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