Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
amazon-drive
Advanced tools
Simple rest client based on the cloud drive API:
https://developer.amazon.com/public/apis/experience/cloud-drive/content/restful-api-getting-started
This is a Promise
based API.
Amazon Drive uses the "Login with Amazon" to authenticate. It is an OAuth workflow that requires visiting an
Amazon login page. This means we need to jump through some hoops to get started. The good news is that you'll
get an acceess_token
and a refresh_token
-- which allows us to renew the credentials programmatically.
In the examples you will see request('./auth.json')
. This file contains the auth object return from a
successful OAuth response. It will look like this:
{
"access_token": "Atza|<really_long_string_of_characters>",
"refresh_token": "Atzr|<really_long_string_of_characters>",
"token_type": "bearer",
"expires_in": 3600
}
The javascript API matches the REST API the best it can.
let urlsCache
const drive = require('amazon-drive')({
cacheUrls: (urls) => {
// urls passed in: save them
if (urls) urlsCache = urls
return Promise.resolve(urlsCache)
},
refresh: () => {
// When this OAuth token expires (401 returned) this will be called.
// You will need to refresh the token and return an updated auth object.
// See: examples/refresh.js
}
})
// get the urls for your account and cache them
drive.getUrls()
.then((urls) => {
console.log(urls.metadataUrl)
console.log(urls.contentUrl)
})
.catch(console.error)
All endpoints will call this internally to retrieve the account's endpoints. If they are retrieved
from the Amazon Drive API, it will call cacheUrls(urls)
for you to cache them somewhere. Amazon
requests that they be cached for 3 to 5 days.
This is what drive.getUrls()
calls- but without caching.
Creates a folder
Thanks to @alex-phillips for the work on node-clouddrive. I used hints in his code and leveraged the authentication server he hosts to help get me started.
See:
FAQs
Amazon Drive API client
We found that amazon-drive demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.