flickr-sdk
Advanced tools
Comparing version 3.0.0 to 3.1.0
@@ -1,2 +0,6 @@ | ||
// Flickr constructor | ||
/*! | ||
* Copyright 2017 Yahoo Holdings. | ||
* Licensed under the terms of the MIT license. Please see LICENSE file in the project root for terms. | ||
*/ | ||
exports = module.exports = require('./services/rest'); | ||
@@ -6,1 +10,4 @@ | ||
exports.OAuth = require('./services/oauth'); | ||
exports.Feeds = require('./services/feeds'); | ||
exports.Upload = require('./services/upload'); | ||
exports.Replace = require('./services/replace'); |
{ | ||
"name": "flickr-sdk", | ||
"version": "3.0.0", | ||
"version": "3.1.0", | ||
"description": "Almost certainly the best Flickr API client in the world for node and the browser", | ||
@@ -15,10 +15,20 @@ "keywords": [ | ||
"index.js", | ||
"request.js", | ||
"lib", | ||
"plugins", | ||
"services" | ||
], | ||
"browser": { | ||
"./plugins/oauth.js": "./plugins/oauth-browser.js", | ||
"./services/oauth.js": "./services/oauth-browser.js" | ||
}, | ||
"scripts": { | ||
"build": "node script/build > services/rest.js", | ||
"reflect": "node script/reflect", | ||
"build-rest": "node script/build-rest > services/rest.js", | ||
"build-tests": "node script/build-tests", | ||
"build-docs": "node script/build-docs > README.md", | ||
"build": "npm run build-rest && npm run build-docs", | ||
"lint": "eslint .", | ||
"test": "istanbul cover _mocha" | ||
"test": "mocha", | ||
"coverage": "nyc mocha", | ||
"prepublish": "npm run build" | ||
}, | ||
@@ -35,16 +45,30 @@ "repository": { | ||
"license": "MIT", | ||
"engines": { | ||
"node": ">= 4" | ||
}, | ||
"publishConfig": { | ||
"tag": "next", | ||
"registry": "https://registry.npmjs.org" | ||
}, | ||
"devDependencies": { | ||
"chalk": "^2.0.1", | ||
"dotprune": "^0.1.10", | ||
"ejs": "~2.5.2", | ||
"es6-promise": "~3.3.1", | ||
"eslint": "~2.13.1", | ||
"eslint": "^4.2.0", | ||
"eslint-config-flickr": "~1.3.1", | ||
"istanbul": "~0.4.5", | ||
"eslint-plugin-header": "^1.0.0", | ||
"indent-string": "^3.1.0", | ||
"jsdoc-to-markdown": "^3.0.0", | ||
"mocha": "~3.0.2", | ||
"nock": "~8.0.0", | ||
"nyc": "^10.3.2", | ||
"ora": "^1.3.0", | ||
"p-limit": "^1.1.0", | ||
"require-dir": "~0.3.1", | ||
"sinon": "~1.17.6" | ||
"sinon": "~1.17.6", | ||
"stringify-object": "^3.2.0" | ||
}, | ||
"dependencies": { | ||
"deepmerge": "^1.1.1", | ||
"superagent": "~2.2.0" | ||
"superagent": "^3.5.3-beta.2", | ||
"xml2js": "^0.4.17" | ||
}, | ||
@@ -51,0 +75,0 @@ "bugs": { |
@@ -1,9 +0,18 @@ | ||
var OAuth = require('../services/oauth'); | ||
/*! | ||
* Copyright 2017 Yahoo Holdings. | ||
* Licensed under the terms of the MIT license. Please see LICENSE file in the project root for terms. | ||
*/ | ||
var OAuth = require('../lib/oauth'); | ||
/** | ||
* Creates a superagent plugin to sign API calls using OAuth 1.0. | ||
* You must provide `oauthToken` and `oauthTokenSecret` when signing | ||
* calls to the Flickr API, or you may pass `false` to explicitly | ||
* omit one or both of these parameters, as is the case for the | ||
* OAuth 1.0 flow in /services/oauth. | ||
* @param {String} consumerKey | ||
* @param {String} consumerSecret | ||
* @param {String} oauthToken | ||
* @param {String} oauthTokenSecret | ||
* @param {String|false} oauthToken | ||
* @param {String|false} oauthTokenSecret | ||
* @returns {Function} | ||
@@ -17,6 +26,6 @@ * @see https://github.com/visionmedia/superagent | ||
if (!oauthToken) { | ||
if (!oauthToken && oauthToken !== false) { | ||
throw new Error('Missing required argument "oauthToken"'); | ||
} | ||
if (!oauthTokenSecret) { | ||
if (!oauthTokenSecret && oauthTokenSecret !== false) { | ||
throw new Error('Missing required argument "oauthTokenSecret"'); | ||
@@ -26,6 +35,33 @@ } | ||
return function (req) { | ||
req.query(oauth.params()); | ||
req.query({ oauth_token: oauthToken }); | ||
req.use(oauth.sign(oauthTokenSecret)); | ||
// we need to overwrite .end to make sure we | ||
// sign the request at the last possible moment | ||
var _end = req.end; | ||
req.end = function (fn) { | ||
// sign the url with token secret unless it was | ||
// explicitly omitted | ||
if (oauthTokenSecret !== false) { | ||
this.param({ | ||
oauth_signature: oauth.signature(this.method, this.url, this.params, oauthTokenSecret) | ||
}); | ||
} else { | ||
this.param({ | ||
oauth_signature: oauth.signature(this.method, this.url, this.params) | ||
}); | ||
} | ||
// call the original | ||
_end.call(this, fn); | ||
}; | ||
// always add our oauth params | ||
req.param(oauth.params()); | ||
// add the oauth token unless explicitly omitted | ||
if (oauthToken !== false) { | ||
req.param({ oauth_token: oauthToken }); | ||
} | ||
}; | ||
}; |
731
README.md
# flickr-sdk | ||
> TODO everything | ||
Almost certainly the best Flickr API client in the world for node and the browser | ||
## use | ||
## Install | ||
### getting a public photo | ||
``` | ||
flickrSDK({ api_key: 'abcd1234', photo_id: '12345678'})('flickr.photos.getInfo') | ||
.then(function (res) { | ||
// get the photo data off res | ||
$ npm install flickr-sdk | ||
``` | ||
## Usage | ||
flickr-sdk is based on [superagent][] and all methods that make API calls will return a superagent Request instance configured for the request. This means that you can do anything with Flickr requests that you can do with superagent. | ||
The Flickr API is divided into several services: | ||
- The [REST API][services/api] service, which provides access to Flickr data | ||
- The [OAuth][services/oauth] service, which authenticates users via OAuth 1.0 | ||
- The [Feeds][services/feeds] service, which provides feeds of public Flickr data | ||
- The [Upload][services/upload] service, where you can upload photos! | ||
- The [Replace][services/replace] service, where you can replace photos you previously uploaded | ||
**Example** | ||
``` js | ||
var Flickr = require('flickr-sdk'); | ||
``` | ||
<a name="Flickr"></a> | ||
## Flickr | ||
All of the [REST API][services/api] methods are available on the | ||
[Flickr](#Flickr) prototype. Each method accepts a single parameter | ||
which is an optional hash of arguments. Refer to the [REST API][services/api] | ||
docs for the full list of methods and their supported arguments. | ||
| Method | Permissions | Required Arguments | | ||
| --- | --- | --- | | ||
| [flickr.activity.userComments](https://www.flickr.com/services/api/flickr.activity.userComments.html) | `read` :eyes: | | | ||
| [flickr.activity.userPhotos](https://www.flickr.com/services/api/flickr.activity.userPhotos.html) | `read` :eyes: | | | ||
| [flickr.auth.checkToken](https://www.flickr.com/services/api/flickr.auth.checkToken.html) | `none` | `auth_token` | | ||
| [flickr.auth.getFrob](https://www.flickr.com/services/api/flickr.auth.getFrob.html) | `none` | | | ||
| [flickr.auth.getFullToken](https://www.flickr.com/services/api/flickr.auth.getFullToken.html) | `none` | `mini_token` | | ||
| [flickr.auth.getToken](https://www.flickr.com/services/api/flickr.auth.getToken.html) | `none` | `frob` | | ||
| [flickr.auth.oauth.checkToken](https://www.flickr.com/services/api/flickr.auth.oauth.checkToken.html) | `none` | `oauth_token` | | ||
| [flickr.auth.oauth.getAccessToken](https://www.flickr.com/services/api/flickr.auth.oauth.getAccessToken.html) | `none` | | | ||
| [flickr.blogs.getList](https://www.flickr.com/services/api/flickr.blogs.getList.html) | `read` :eyes: | | | ||
| [flickr.blogs.getServices](https://www.flickr.com/services/api/flickr.blogs.getServices.html) | `none` | | | ||
| [flickr.blogs.postPhoto](https://www.flickr.com/services/api/flickr.blogs.postPhoto.html) | `write` :pencil2: | `photo_id`, `title`, `description` | | ||
| [flickr.cameras.getBrandModels](https://www.flickr.com/services/api/flickr.cameras.getBrandModels.html) | `none` | `brand` | | ||
| [flickr.cameras.getBrands](https://www.flickr.com/services/api/flickr.cameras.getBrands.html) | `none` | | | ||
| [flickr.collections.getInfo](https://www.flickr.com/services/api/flickr.collections.getInfo.html) | `read` :eyes: | `collection_id` | | ||
| [flickr.collections.getTree](https://www.flickr.com/services/api/flickr.collections.getTree.html) | `none` | | | ||
| [flickr.commons.getInstitutions](https://www.flickr.com/services/api/flickr.commons.getInstitutions.html) | `none` | | | ||
| [flickr.contacts.getList](https://www.flickr.com/services/api/flickr.contacts.getList.html) | `read` :eyes: | | | ||
| [flickr.contacts.getListRecentlyUploaded](https://www.flickr.com/services/api/flickr.contacts.getListRecentlyUploaded.html) | `read` :eyes: | | | ||
| [flickr.contacts.getPublicList](https://www.flickr.com/services/api/flickr.contacts.getPublicList.html) | `none` | `user_id` | | ||
| [flickr.contacts.getTaggingSuggestions](https://www.flickr.com/services/api/flickr.contacts.getTaggingSuggestions.html) | `read` :eyes: | | | ||
| [flickr.favorites.add](https://www.flickr.com/services/api/flickr.favorites.add.html) | `write` :pencil2: | `photo_id` | | ||
| [flickr.favorites.getContext](https://www.flickr.com/services/api/flickr.favorites.getContext.html) | `none` | `photo_id`, `user_id` | | ||
| [flickr.favorites.getList](https://www.flickr.com/services/api/flickr.favorites.getList.html) | `none` | | | ||
| [flickr.favorites.getPublicList](https://www.flickr.com/services/api/flickr.favorites.getPublicList.html) | `none` | `user_id` | | ||
| [flickr.favorites.remove](https://www.flickr.com/services/api/flickr.favorites.remove.html) | `write` :pencil2: | `photo_id` | | ||
| [flickr.galleries.addPhoto](https://www.flickr.com/services/api/flickr.galleries.addPhoto.html) | `write` :pencil2: | `gallery_id`, `photo_id` | | ||
| [flickr.galleries.create](https://www.flickr.com/services/api/flickr.galleries.create.html) | `write` :pencil2: | `title`, `description` | | ||
| [flickr.galleries.editMeta](https://www.flickr.com/services/api/flickr.galleries.editMeta.html) | `write` :pencil2: | `gallery_id`, `title` | | ||
| [flickr.galleries.editPhoto](https://www.flickr.com/services/api/flickr.galleries.editPhoto.html) | `write` :pencil2: | `gallery_id`, `photo_id`, `comment` | | ||
| [flickr.galleries.editPhotos](https://www.flickr.com/services/api/flickr.galleries.editPhotos.html) | `write` :pencil2: | `gallery_id`, `primary_photo_id`, `photo_ids` | | ||
| [flickr.galleries.getInfo](https://www.flickr.com/services/api/flickr.galleries.getInfo.html) | `none` | `gallery_id` | | ||
| [flickr.galleries.getList](https://www.flickr.com/services/api/flickr.galleries.getList.html) | `none` | `user_id` | | ||
| [flickr.galleries.getListForPhoto](https://www.flickr.com/services/api/flickr.galleries.getListForPhoto.html) | `none` | `photo_id` | | ||
| [flickr.galleries.getPhotos](https://www.flickr.com/services/api/flickr.galleries.getPhotos.html) | `none` | `gallery_id` | | ||
| [flickr.groups.browse](https://www.flickr.com/services/api/flickr.groups.browse.html) | `read` :eyes: | | | ||
| [flickr.groups.getInfo](https://www.flickr.com/services/api/flickr.groups.getInfo.html) | `none` | `group_id` | | ||
| [flickr.groups.join](https://www.flickr.com/services/api/flickr.groups.join.html) | `write` :pencil2: | `group_id` | | ||
| [flickr.groups.joinRequest](https://www.flickr.com/services/api/flickr.groups.joinRequest.html) | `write` :pencil2: | `group_id`, `message`, `accept_rules` | | ||
| [flickr.groups.leave](https://www.flickr.com/services/api/flickr.groups.leave.html) | `delete` :boom: | `group_id` | | ||
| [flickr.groups.search](https://www.flickr.com/services/api/flickr.groups.search.html) | `none` | `text` | | ||
| [flickr.groups.discuss.replies.add](https://www.flickr.com/services/api/flickr.groups.discuss.replies.add.html) | `write` :pencil2: | `group_id`, `topic_id`, `message` | | ||
| [flickr.groups.discuss.replies.delete](https://www.flickr.com/services/api/flickr.groups.discuss.replies.delete.html) | `delete` :boom: | `group_id`, `topic_id`, `reply_id` | | ||
| [flickr.groups.discuss.replies.edit](https://www.flickr.com/services/api/flickr.groups.discuss.replies.edit.html) | `write` :pencil2: | `group_id`, `topic_id`, `reply_id`, `message` | | ||
| [flickr.groups.discuss.replies.getInfo](https://www.flickr.com/services/api/flickr.groups.discuss.replies.getInfo.html) | `none` | `group_id`, `topic_id`, `reply_id` | | ||
| [flickr.groups.discuss.replies.getList](https://www.flickr.com/services/api/flickr.groups.discuss.replies.getList.html) | `none` | `group_id`, `topic_id`, `per_page` | | ||
| [flickr.groups.discuss.topics.add](https://www.flickr.com/services/api/flickr.groups.discuss.topics.add.html) | `write` :pencil2: | `group_id`, `subject`, `message` | | ||
| [flickr.groups.discuss.topics.getInfo](https://www.flickr.com/services/api/flickr.groups.discuss.topics.getInfo.html) | `none` | `group_id`, `topic_id` | | ||
| [flickr.groups.discuss.topics.getList](https://www.flickr.com/services/api/flickr.groups.discuss.topics.getList.html) | `none` | `group_id` | | ||
| [flickr.groups.members.getList](https://www.flickr.com/services/api/flickr.groups.members.getList.html) | `read` :eyes: | `group_id` | | ||
| [flickr.groups.pools.add](https://www.flickr.com/services/api/flickr.groups.pools.add.html) | `write` :pencil2: | `photo_id`, `group_id` | | ||
| [flickr.groups.pools.getContext](https://www.flickr.com/services/api/flickr.groups.pools.getContext.html) | `none` | `photo_id`, `group_id` | | ||
| [flickr.groups.pools.getGroups](https://www.flickr.com/services/api/flickr.groups.pools.getGroups.html) | `read` :eyes: | | | ||
| [flickr.groups.pools.getPhotos](https://www.flickr.com/services/api/flickr.groups.pools.getPhotos.html) | `none` | `group_id` | | ||
| [flickr.groups.pools.remove](https://www.flickr.com/services/api/flickr.groups.pools.remove.html) | `write` :pencil2: | `photo_id`, `group_id` | | ||
| [flickr.interestingness.getList](https://www.flickr.com/services/api/flickr.interestingness.getList.html) | `none` | | | ||
| [flickr.machinetags.getNamespaces](https://www.flickr.com/services/api/flickr.machinetags.getNamespaces.html) | `none` | | | ||
| [flickr.machinetags.getPairs](https://www.flickr.com/services/api/flickr.machinetags.getPairs.html) | `none` | | | ||
| [flickr.machinetags.getPredicates](https://www.flickr.com/services/api/flickr.machinetags.getPredicates.html) | `none` | | | ||
| [flickr.machinetags.getRecentValues](https://www.flickr.com/services/api/flickr.machinetags.getRecentValues.html) | `none` | | | ||
| [flickr.machinetags.getValues](https://www.flickr.com/services/api/flickr.machinetags.getValues.html) | `none` | `namespace`, `predicate` | | ||
| [flickr.panda.getList](https://www.flickr.com/services/api/flickr.panda.getList.html) | `none` | | | ||
| [flickr.panda.getPhotos](https://www.flickr.com/services/api/flickr.panda.getPhotos.html) | `none` | `panda_name` | | ||
| [flickr.people.findByEmail](https://www.flickr.com/services/api/flickr.people.findByEmail.html) | `none` | `find_email` | | ||
| [flickr.people.findByUsername](https://www.flickr.com/services/api/flickr.people.findByUsername.html) | `none` | `username` | | ||
| [flickr.people.getGroups](https://www.flickr.com/services/api/flickr.people.getGroups.html) | `read` :eyes: | `user_id` | | ||
| [flickr.people.getInfo](https://www.flickr.com/services/api/flickr.people.getInfo.html) | `none` | `user_id` | | ||
| [flickr.people.getLimits](https://www.flickr.com/services/api/flickr.people.getLimits.html) | `read` :eyes: | | | ||
| [flickr.people.getPhotos](https://www.flickr.com/services/api/flickr.people.getPhotos.html) | `none` | `user_id` | | ||
| [flickr.people.getPhotosOf](https://www.flickr.com/services/api/flickr.people.getPhotosOf.html) | `none` | `user_id` | | ||
| [flickr.people.getPublicGroups](https://www.flickr.com/services/api/flickr.people.getPublicGroups.html) | `none` | `user_id` | | ||
| [flickr.people.getPublicPhotos](https://www.flickr.com/services/api/flickr.people.getPublicPhotos.html) | `none` | `user_id` | | ||
| [flickr.people.getUploadStatus](https://www.flickr.com/services/api/flickr.people.getUploadStatus.html) | `read` :eyes: | | | ||
| [flickr.photos.addTags](https://www.flickr.com/services/api/flickr.photos.addTags.html) | `write` :pencil2: | `photo_id`, `tags` | | ||
| [flickr.photos.delete](https://www.flickr.com/services/api/flickr.photos.delete.html) | `delete` :boom: | `photo_id` | | ||
| [flickr.photos.getAllContexts](https://www.flickr.com/services/api/flickr.photos.getAllContexts.html) | `none` | `photo_id` | | ||
| [flickr.photos.getContactsPhotos](https://www.flickr.com/services/api/flickr.photos.getContactsPhotos.html) | `read` :eyes: | | | ||
| [flickr.photos.getContactsPublicPhotos](https://www.flickr.com/services/api/flickr.photos.getContactsPublicPhotos.html) | `none` | `user_id` | | ||
| [flickr.photos.getContext](https://www.flickr.com/services/api/flickr.photos.getContext.html) | `none` | `photo_id` | | ||
| [flickr.photos.getCounts](https://www.flickr.com/services/api/flickr.photos.getCounts.html) | `read` :eyes: | | | ||
| [flickr.photos.getExif](https://www.flickr.com/services/api/flickr.photos.getExif.html) | `none` | `photo_id` | | ||
| [flickr.photos.getFavorites](https://www.flickr.com/services/api/flickr.photos.getFavorites.html) | `none` | `photo_id` | | ||
| [flickr.photos.getInfo](https://www.flickr.com/services/api/flickr.photos.getInfo.html) | `none` | `photo_id` | | ||
| [flickr.photos.getNotInSet](https://www.flickr.com/services/api/flickr.photos.getNotInSet.html) | `read` :eyes: | | | ||
| [flickr.photos.getPerms](https://www.flickr.com/services/api/flickr.photos.getPerms.html) | `read` :eyes: | `photo_id` | | ||
| [flickr.photos.getPopular](https://www.flickr.com/services/api/flickr.photos.getPopular.html) | `none` | | | ||
| [flickr.photos.getRecent](https://www.flickr.com/services/api/flickr.photos.getRecent.html) | `none` | | | ||
| [flickr.photos.getSizes](https://www.flickr.com/services/api/flickr.photos.getSizes.html) | `none` | `photo_id` | | ||
| [flickr.photos.getUntagged](https://www.flickr.com/services/api/flickr.photos.getUntagged.html) | `read` :eyes: | | | ||
| [flickr.photos.getWithGeoData](https://www.flickr.com/services/api/flickr.photos.getWithGeoData.html) | `read` :eyes: | | | ||
| [flickr.photos.getWithoutGeoData](https://www.flickr.com/services/api/flickr.photos.getWithoutGeoData.html) | `read` :eyes: | | | ||
| [flickr.photos.recentlyUpdated](https://www.flickr.com/services/api/flickr.photos.recentlyUpdated.html) | `read` :eyes: | `min_date` | | ||
| [flickr.photos.removeTag](https://www.flickr.com/services/api/flickr.photos.removeTag.html) | `write` :pencil2: | `tag_id` | | ||
| [flickr.photos.search](https://www.flickr.com/services/api/flickr.photos.search.html) | `none` | | | ||
| [flickr.photos.setContentType](https://www.flickr.com/services/api/flickr.photos.setContentType.html) | `write` :pencil2: | `photo_id`, `content_type` | | ||
| [flickr.photos.setDates](https://www.flickr.com/services/api/flickr.photos.setDates.html) | `write` :pencil2: | `photo_id` | | ||
| [flickr.photos.setMeta](https://www.flickr.com/services/api/flickr.photos.setMeta.html) | `write` :pencil2: | `photo_id` | | ||
| [flickr.photos.setPerms](https://www.flickr.com/services/api/flickr.photos.setPerms.html) | `write` :pencil2: | `photo_id`, `is_public`, `is_friend`, `is_family` | | ||
| [flickr.photos.setSafetyLevel](https://www.flickr.com/services/api/flickr.photos.setSafetyLevel.html) | `write` :pencil2: | `photo_id` | | ||
| [flickr.photos.setTags](https://www.flickr.com/services/api/flickr.photos.setTags.html) | `write` :pencil2: | `photo_id`, `tags` | | ||
| [flickr.photos.comments.addComment](https://www.flickr.com/services/api/flickr.photos.comments.addComment.html) | `write` :pencil2: | `photo_id`, `comment_text` | | ||
| [flickr.photos.comments.deleteComment](https://www.flickr.com/services/api/flickr.photos.comments.deleteComment.html) | `write` :pencil2: | `comment_id` | | ||
| [flickr.photos.comments.editComment](https://www.flickr.com/services/api/flickr.photos.comments.editComment.html) | `write` :pencil2: | `comment_id`, `comment_text` | | ||
| [flickr.photos.comments.getList](https://www.flickr.com/services/api/flickr.photos.comments.getList.html) | `none` | `photo_id` | | ||
| [flickr.photos.comments.getRecentForContacts](https://www.flickr.com/services/api/flickr.photos.comments.getRecentForContacts.html) | `read` :eyes: | | | ||
| [flickr.photos.geo.batchCorrectLocation](https://www.flickr.com/services/api/flickr.photos.geo.batchCorrectLocation.html) | `write` :pencil2: | `lat`, `lon`, `accuracy` | | ||
| [flickr.photos.geo.correctLocation](https://www.flickr.com/services/api/flickr.photos.geo.correctLocation.html) | `write` :pencil2: | `photo_id`, `foursquare_id` | | ||
| [flickr.photos.geo.getLocation](https://www.flickr.com/services/api/flickr.photos.geo.getLocation.html) | `none` | `photo_id` | | ||
| [flickr.photos.geo.getPerms](https://www.flickr.com/services/api/flickr.photos.geo.getPerms.html) | `read` :eyes: | `photo_id` | | ||
| [flickr.photos.geo.photosForLocation](https://www.flickr.com/services/api/flickr.photos.geo.photosForLocation.html) | `read` :eyes: | `lat`, `lon` | | ||
| [flickr.photos.geo.removeLocation](https://www.flickr.com/services/api/flickr.photos.geo.removeLocation.html) | `write` :pencil2: | `photo_id` | | ||
| [flickr.photos.geo.setContext](https://www.flickr.com/services/api/flickr.photos.geo.setContext.html) | `write` :pencil2: | `photo_id`, `context` | | ||
| [flickr.photos.geo.setLocation](https://www.flickr.com/services/api/flickr.photos.geo.setLocation.html) | `write` :pencil2: | `photo_id`, `lat`, `lon` | | ||
| [flickr.photos.geo.setPerms](https://www.flickr.com/services/api/flickr.photos.geo.setPerms.html) | `write` :pencil2: | `is_public`, `is_contact`, `is_friend`, `is_family`, `photo_id` | | ||
| [flickr.photos.licenses.getInfo](https://www.flickr.com/services/api/flickr.photos.licenses.getInfo.html) | `none` | | | ||
| [flickr.photos.licenses.setLicense](https://www.flickr.com/services/api/flickr.photos.licenses.setLicense.html) | `write` :pencil2: | `photo_id`, `license_id` | | ||
| [flickr.photos.notes.add](https://www.flickr.com/services/api/flickr.photos.notes.add.html) | `write` :pencil2: | `photo_id`, `note_x`, `note_y`, `note_w`, `note_h`, `note_text` | | ||
| [flickr.photos.notes.delete](https://www.flickr.com/services/api/flickr.photos.notes.delete.html) | `write` :pencil2: | `note_id` | | ||
| [flickr.photos.notes.edit](https://www.flickr.com/services/api/flickr.photos.notes.edit.html) | `write` :pencil2: | `note_id`, `note_x`, `note_y`, `note_w`, `note_h`, `note_text` | | ||
| [flickr.photos.people.add](https://www.flickr.com/services/api/flickr.photos.people.add.html) | `write` :pencil2: | `photo_id`, `user_id` | | ||
| [flickr.photos.people.delete](https://www.flickr.com/services/api/flickr.photos.people.delete.html) | `write` :pencil2: | `photo_id`, `user_id` | | ||
| [flickr.photos.people.deleteCoords](https://www.flickr.com/services/api/flickr.photos.people.deleteCoords.html) | `write` :pencil2: | `photo_id`, `user_id` | | ||
| [flickr.photos.people.editCoords](https://www.flickr.com/services/api/flickr.photos.people.editCoords.html) | `write` :pencil2: | `photo_id`, `user_id`, `person_x`, `person_y`, `person_w`, `person_h` | | ||
| [flickr.photos.people.getList](https://www.flickr.com/services/api/flickr.photos.people.getList.html) | `none` | `photo_id` | | ||
| [flickr.photos.suggestions.approveSuggestion](https://www.flickr.com/services/api/flickr.photos.suggestions.approveSuggestion.html) | `write` :pencil2: | `suggestion_id` | | ||
| [flickr.photos.suggestions.getList](https://www.flickr.com/services/api/flickr.photos.suggestions.getList.html) | `read` :eyes: | | | ||
| [flickr.photos.suggestions.rejectSuggestion](https://www.flickr.com/services/api/flickr.photos.suggestions.rejectSuggestion.html) | `write` :pencil2: | `suggestion_id` | | ||
| [flickr.photos.suggestions.removeSuggestion](https://www.flickr.com/services/api/flickr.photos.suggestions.removeSuggestion.html) | `write` :pencil2: | `suggestion_id` | | ||
| [flickr.photos.suggestions.suggestLocation](https://www.flickr.com/services/api/flickr.photos.suggestions.suggestLocation.html) | `write` :pencil2: | `photo_id`, `lat`, `lon` | | ||
| [flickr.photos.transform.rotate](https://www.flickr.com/services/api/flickr.photos.transform.rotate.html) | `write` :pencil2: | `photo_id`, `degrees` | | ||
| [flickr.photos.upload.checkTickets](https://www.flickr.com/services/api/flickr.photos.upload.checkTickets.html) | `none` | `tickets` | | ||
| [flickr.photosets.addPhoto](https://www.flickr.com/services/api/flickr.photosets.addPhoto.html) | `write` :pencil2: | `photoset_id`, `photo_id` | | ||
| [flickr.photosets.create](https://www.flickr.com/services/api/flickr.photosets.create.html) | `write` :pencil2: | `title`, `primary_photo_id` | | ||
| [flickr.photosets.delete](https://www.flickr.com/services/api/flickr.photosets.delete.html) | `write` :pencil2: | `photoset_id` | | ||
| [flickr.photosets.editMeta](https://www.flickr.com/services/api/flickr.photosets.editMeta.html) | `write` :pencil2: | `photoset_id`, `title` | | ||
| [flickr.photosets.editPhotos](https://www.flickr.com/services/api/flickr.photosets.editPhotos.html) | `write` :pencil2: | `photoset_id`, `primary_photo_id`, `photo_ids` | | ||
| [flickr.photosets.getContext](https://www.flickr.com/services/api/flickr.photosets.getContext.html) | `none` | `photo_id`, `photoset_id` | | ||
| [flickr.photosets.getInfo](https://www.flickr.com/services/api/flickr.photosets.getInfo.html) | `none` | `photoset_id`, `user_id` | | ||
| [flickr.photosets.getList](https://www.flickr.com/services/api/flickr.photosets.getList.html) | `none` | | | ||
| [flickr.photosets.getPhotos](https://www.flickr.com/services/api/flickr.photosets.getPhotos.html) | `none` | `photoset_id`, `user_id` | | ||
| [flickr.photosets.orderSets](https://www.flickr.com/services/api/flickr.photosets.orderSets.html) | `write` :pencil2: | `photoset_ids` | | ||
| [flickr.photosets.removePhoto](https://www.flickr.com/services/api/flickr.photosets.removePhoto.html) | `write` :pencil2: | `photoset_id`, `photo_id` | | ||
| [flickr.photosets.removePhotos](https://www.flickr.com/services/api/flickr.photosets.removePhotos.html) | `write` :pencil2: | `photoset_id`, `photo_ids` | | ||
| [flickr.photosets.reorderPhotos](https://www.flickr.com/services/api/flickr.photosets.reorderPhotos.html) | `write` :pencil2: | `photoset_id`, `photo_ids` | | ||
| [flickr.photosets.setPrimaryPhoto](https://www.flickr.com/services/api/flickr.photosets.setPrimaryPhoto.html) | `write` :pencil2: | `photoset_id`, `photo_id` | | ||
| [flickr.photosets.comments.addComment](https://www.flickr.com/services/api/flickr.photosets.comments.addComment.html) | `write` :pencil2: | `photoset_id`, `comment_text` | | ||
| [flickr.photosets.comments.deleteComment](https://www.flickr.com/services/api/flickr.photosets.comments.deleteComment.html) | `write` :pencil2: | `comment_id` | | ||
| [flickr.photosets.comments.editComment](https://www.flickr.com/services/api/flickr.photosets.comments.editComment.html) | `write` :pencil2: | `comment_id`, `comment_text` | | ||
| [flickr.photosets.comments.getList](https://www.flickr.com/services/api/flickr.photosets.comments.getList.html) | `none` | `photoset_id` | | ||
| [flickr.places.find](https://www.flickr.com/services/api/flickr.places.find.html) | `none` | `query` | | ||
| [flickr.places.findByLatLon](https://www.flickr.com/services/api/flickr.places.findByLatLon.html) | `none` | `lat`, `lon` | | ||
| [flickr.places.getChildrenWithPhotosPublic](https://www.flickr.com/services/api/flickr.places.getChildrenWithPhotosPublic.html) | `none` | | | ||
| [flickr.places.getInfo](https://www.flickr.com/services/api/flickr.places.getInfo.html) | `none` | | | ||
| [flickr.places.getInfoByUrl](https://www.flickr.com/services/api/flickr.places.getInfoByUrl.html) | `none` | `url` | | ||
| [flickr.places.getPlaceTypes](https://www.flickr.com/services/api/flickr.places.getPlaceTypes.html) | `none` | | | ||
| [flickr.places.getShapeHistory](https://www.flickr.com/services/api/flickr.places.getShapeHistory.html) | `none` | | | ||
| [flickr.places.getTopPlacesList](https://www.flickr.com/services/api/flickr.places.getTopPlacesList.html) | `none` | `place_type_id` | | ||
| [flickr.places.placesForBoundingBox](https://www.flickr.com/services/api/flickr.places.placesForBoundingBox.html) | `none` | `bbox` | | ||
| [flickr.places.placesForContacts](https://www.flickr.com/services/api/flickr.places.placesForContacts.html) | `read` :eyes: | | | ||
| [flickr.places.placesForTags](https://www.flickr.com/services/api/flickr.places.placesForTags.html) | `none` | `place_type_id` | | ||
| [flickr.places.placesForUser](https://www.flickr.com/services/api/flickr.places.placesForUser.html) | `read` :eyes: | | | ||
| [flickr.places.resolvePlaceId](https://www.flickr.com/services/api/flickr.places.resolvePlaceId.html) | `none` | `place_id` | | ||
| [flickr.places.resolvePlaceURL](https://www.flickr.com/services/api/flickr.places.resolvePlaceURL.html) | `none` | `url` | | ||
| [flickr.places.tagsForPlace](https://www.flickr.com/services/api/flickr.places.tagsForPlace.html) | `none` | | | ||
| [flickr.prefs.getContentType](https://www.flickr.com/services/api/flickr.prefs.getContentType.html) | `read` :eyes: | | | ||
| [flickr.prefs.getGeoPerms](https://www.flickr.com/services/api/flickr.prefs.getGeoPerms.html) | `read` :eyes: | | | ||
| [flickr.prefs.getHidden](https://www.flickr.com/services/api/flickr.prefs.getHidden.html) | `read` :eyes: | | | ||
| [flickr.prefs.getPrivacy](https://www.flickr.com/services/api/flickr.prefs.getPrivacy.html) | `read` :eyes: | | | ||
| [flickr.prefs.getSafetyLevel](https://www.flickr.com/services/api/flickr.prefs.getSafetyLevel.html) | `read` :eyes: | | | ||
| [flickr.profile.getProfile](https://www.flickr.com/services/api/flickr.profile.getProfile.html) | `none` | `user_id` | | ||
| [flickr.push.getSubscriptions](https://www.flickr.com/services/api/flickr.push.getSubscriptions.html) | `read` :eyes: | | | ||
| [flickr.push.getTopics](https://www.flickr.com/services/api/flickr.push.getTopics.html) | `none` | | | ||
| [flickr.push.subscribe](https://www.flickr.com/services/api/flickr.push.subscribe.html) | `read` :eyes: | `topic`, `callback`, `verify` | | ||
| [flickr.push.unsubscribe](https://www.flickr.com/services/api/flickr.push.unsubscribe.html) | `read` :eyes: | `topic`, `callback`, `verify` | | ||
| [flickr.reflection.getMethodInfo](https://www.flickr.com/services/api/flickr.reflection.getMethodInfo.html) | `none` | `method_name` | | ||
| [flickr.reflection.getMethods](https://www.flickr.com/services/api/flickr.reflection.getMethods.html) | `none` | | | ||
| [flickr.stats.getCSVFiles](https://www.flickr.com/services/api/flickr.stats.getCSVFiles.html) | `read` :eyes: | | | ||
| [flickr.stats.getCollectionDomains](https://www.flickr.com/services/api/flickr.stats.getCollectionDomains.html) | `read` :eyes: | `date` | | ||
| [flickr.stats.getCollectionReferrers](https://www.flickr.com/services/api/flickr.stats.getCollectionReferrers.html) | `read` :eyes: | `date`, `domain` | | ||
| [flickr.stats.getCollectionStats](https://www.flickr.com/services/api/flickr.stats.getCollectionStats.html) | `read` :eyes: | `date`, `collection_id` | | ||
| [flickr.stats.getPhotoDomains](https://www.flickr.com/services/api/flickr.stats.getPhotoDomains.html) | `read` :eyes: | `date` | | ||
| [flickr.stats.getPhotoReferrers](https://www.flickr.com/services/api/flickr.stats.getPhotoReferrers.html) | `read` :eyes: | `date`, `domain` | | ||
| [flickr.stats.getPhotoStats](https://www.flickr.com/services/api/flickr.stats.getPhotoStats.html) | `read` :eyes: | `date`, `photo_id` | | ||
| [flickr.stats.getPhotosetDomains](https://www.flickr.com/services/api/flickr.stats.getPhotosetDomains.html) | `read` :eyes: | `date` | | ||
| [flickr.stats.getPhotosetReferrers](https://www.flickr.com/services/api/flickr.stats.getPhotosetReferrers.html) | `read` :eyes: | `date`, `domain` | | ||
| [flickr.stats.getPhotosetStats](https://www.flickr.com/services/api/flickr.stats.getPhotosetStats.html) | `read` :eyes: | `date`, `photoset_id` | | ||
| [flickr.stats.getPhotostreamDomains](https://www.flickr.com/services/api/flickr.stats.getPhotostreamDomains.html) | `read` :eyes: | `date` | | ||
| [flickr.stats.getPhotostreamReferrers](https://www.flickr.com/services/api/flickr.stats.getPhotostreamReferrers.html) | `read` :eyes: | `date`, `domain` | | ||
| [flickr.stats.getPhotostreamStats](https://www.flickr.com/services/api/flickr.stats.getPhotostreamStats.html) | `read` :eyes: | `date` | | ||
| [flickr.stats.getPopularPhotos](https://www.flickr.com/services/api/flickr.stats.getPopularPhotos.html) | `read` :eyes: | | | ||
| [flickr.stats.getTotalViews](https://www.flickr.com/services/api/flickr.stats.getTotalViews.html) | `read` :eyes: | | | ||
| [flickr.tags.getClusterPhotos](https://www.flickr.com/services/api/flickr.tags.getClusterPhotos.html) | `none` | `tag`, `cluster_id` | | ||
| [flickr.tags.getClusters](https://www.flickr.com/services/api/flickr.tags.getClusters.html) | `none` | `tag` | | ||
| [flickr.tags.getHotList](https://www.flickr.com/services/api/flickr.tags.getHotList.html) | `none` | | | ||
| [flickr.tags.getListPhoto](https://www.flickr.com/services/api/flickr.tags.getListPhoto.html) | `none` | `photo_id` | | ||
| [flickr.tags.getListUser](https://www.flickr.com/services/api/flickr.tags.getListUser.html) | `none` | | | ||
| [flickr.tags.getListUserPopular](https://www.flickr.com/services/api/flickr.tags.getListUserPopular.html) | `none` | | | ||
| [flickr.tags.getListUserRaw](https://www.flickr.com/services/api/flickr.tags.getListUserRaw.html) | `none` | | | ||
| [flickr.tags.getMostFrequentlyUsed](https://www.flickr.com/services/api/flickr.tags.getMostFrequentlyUsed.html) | `read` :eyes: | | | ||
| [flickr.tags.getRelated](https://www.flickr.com/services/api/flickr.tags.getRelated.html) | `none` | `tag` | | ||
| [flickr.test.echo](https://www.flickr.com/services/api/flickr.test.echo.html) | `none` | | | ||
| [flickr.test.login](https://www.flickr.com/services/api/flickr.test.login.html) | `read` :eyes: | | | ||
| [flickr.test.null](https://www.flickr.com/services/api/flickr.test.null.html) | `read` :eyes: | | | ||
| [flickr.testimonials.addTestimonial](https://www.flickr.com/services/api/flickr.testimonials.addTestimonial.html) | `write` :pencil2: | `user_id`, `testimonial_text` | | ||
| [flickr.testimonials.approveTestimonial](https://www.flickr.com/services/api/flickr.testimonials.approveTestimonial.html) | `write` :pencil2: | `testimonial_id` | | ||
| [flickr.testimonials.deleteTestimonial](https://www.flickr.com/services/api/flickr.testimonials.deleteTestimonial.html) | `write` :pencil2: | `testimonial_id` | | ||
| [flickr.testimonials.editTestimonial](https://www.flickr.com/services/api/flickr.testimonials.editTestimonial.html) | `write` :pencil2: | `user_id`, `testimonial_id`, `testimonial_text` | | ||
| [flickr.testimonials.getAllTestimonialsAbout](https://www.flickr.com/services/api/flickr.testimonials.getAllTestimonialsAbout.html) | `read` :eyes: | | | ||
| [flickr.testimonials.getAllTestimonialsAboutBy](https://www.flickr.com/services/api/flickr.testimonials.getAllTestimonialsAboutBy.html) | `read` :eyes: | `user_id` | | ||
| [flickr.testimonials.getAllTestimonialsBy](https://www.flickr.com/services/api/flickr.testimonials.getAllTestimonialsBy.html) | `read` :eyes: | | | ||
| [flickr.testimonials.getPendingTestimonialsAbout](https://www.flickr.com/services/api/flickr.testimonials.getPendingTestimonialsAbout.html) | `read` :eyes: | | | ||
| [flickr.testimonials.getPendingTestimonialsAboutBy](https://www.flickr.com/services/api/flickr.testimonials.getPendingTestimonialsAboutBy.html) | `read` :eyes: | `user_id` | | ||
| [flickr.testimonials.getPendingTestimonialsBy](https://www.flickr.com/services/api/flickr.testimonials.getPendingTestimonialsBy.html) | `read` :eyes: | | | ||
| [flickr.testimonials.getTestimonialsAbout](https://www.flickr.com/services/api/flickr.testimonials.getTestimonialsAbout.html) | `none` | `user_id` | | ||
| [flickr.testimonials.getTestimonialsAboutBy](https://www.flickr.com/services/api/flickr.testimonials.getTestimonialsAboutBy.html) | `read` :eyes: | `user_id` | | ||
| [flickr.testimonials.getTestimonialsBy](https://www.flickr.com/services/api/flickr.testimonials.getTestimonialsBy.html) | `none` | `user_id` | | ||
| [flickr.urls.getGroup](https://www.flickr.com/services/api/flickr.urls.getGroup.html) | `none` | `group_id` | | ||
| [flickr.urls.getUserPhotos](https://www.flickr.com/services/api/flickr.urls.getUserPhotos.html) | `none` | | | ||
| [flickr.urls.getUserProfile](https://www.flickr.com/services/api/flickr.urls.getUserProfile.html) | `none` | | | ||
| [flickr.urls.lookupGallery](https://www.flickr.com/services/api/flickr.urls.lookupGallery.html) | `none` | `url` | | ||
| [flickr.urls.lookupGroup](https://www.flickr.com/services/api/flickr.urls.lookupGroup.html) | `none` | `url` | | ||
| [flickr.urls.lookupUser](https://www.flickr.com/services/api/flickr.urls.lookupUser.html) | `none` | `url` | | ||
**Kind**: global class | ||
* [Flickr](#Flickr) | ||
* [new Flickr(auth)](#new_Flickr_new) | ||
* [.OAuth](#Flickr.OAuth) | ||
* [new OAuth(consumerKey, consumerSecret)](#new_Flickr.OAuth_new) | ||
* _instance_ | ||
* [.request(oauthCallback)](#Flickr.OAuth+request) ⇒ <code>Request</code> | ||
* [.authorizeUrl(requestToken, [perms])](#Flickr.OAuth+authorizeUrl) ⇒ <code>String</code> | ||
* [.verify(oauthToken, oauthVerifier, tokenSecret)](#Flickr.OAuth+verify) ⇒ <code>Request</code> | ||
* [.plugin(oauthToken, oauthTokenSecret)](#Flickr.OAuth+plugin) ⇒ <code>function</code> | ||
* _static_ | ||
* [.createPlugin(consumerKey, consumerSecret, oauthToken, oauthTokenSecret)](#Flickr.OAuth.createPlugin) ⇒ <code>function</code> | ||
* [.Upload](#Flickr.Upload) ⇐ <code>Request</code> | ||
* [new Upload(auth, file, [args])](#new_Flickr.Upload_new) | ||
* [.Replace](#Flickr.Replace) ⇐ <code>Request</code> | ||
* [new Replace(auth, photoID, file, [args])](#new_Flickr.Replace_new) | ||
* [.Feeds](#Flickr.Feeds) | ||
* [new Feeds([args])](#new_Flickr.Feeds_new) | ||
* [.publicPhotos([args])](#Flickr.Feeds+publicPhotos) ⇒ <code>Request</code> | ||
* [.friendsPhotos(args)](#Flickr.Feeds+friendsPhotos) ⇒ <code>Request</code> | ||
* [.favePhotos(args)](#Flickr.Feeds+favePhotos) ⇒ <code>Request</code> | ||
* [.groupDiscussions(args)](#Flickr.Feeds+groupDiscussions) ⇒ <code>Request</code> | ||
* [.groupPool(args)](#Flickr.Feeds+groupPool) ⇒ <code>Request</code> | ||
* [.forum([args])](#Flickr.Feeds+forum) ⇒ <code>Request</code> | ||
* [.recentActivity(args)](#Flickr.Feeds+recentActivity) ⇒ <code>Request</code> | ||
* [.recentComments(args)](#Flickr.Feeds+recentComments) ⇒ <code>Request</code> | ||
<a name="new_Flickr_new"></a> | ||
### new Flickr(auth) | ||
Creates a new Flickr REST API client. | ||
You **must** pass a superagent plugin or your API key as the first | ||
parameter. For methods that don't require authentication, you can simply | ||
provide your API key. For methods that do require authentication, | ||
use the [OAuth plugin](#Flickr.OAuth.createPlugin). | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| auth | <code>function</code> \| <code>String</code> | An authentication plugin function or an API key | | ||
**Example** *(Get info about a public photo with your API key)* | ||
```js | ||
var flickr = new Flickr(process.env.FLICKR_API_KEY); | ||
flickr.photos.getInfo({ | ||
photo_id: 25825763 // sorry, @dokas | ||
}).then(function (res) { | ||
console.log('yay!', res.body); | ||
}).catch(function (err) { | ||
console.error('bonk', err); | ||
}); | ||
``` | ||
**Example** *(Searching for public photos with your API key)* | ||
```js | ||
### getting a private photo | ||
var flickr = new Flickr(process.env.FLICKR_API_KEY); | ||
flickr.photos.search({ | ||
text: 'doggo' | ||
}).then(function (res) { | ||
console.log('yay!', res.body); | ||
}).catch(function (err) { | ||
console.error('bonk', err); | ||
}); | ||
``` | ||
require('flickrSDK')({ api_key: 'abcd1234', photo_id: '987654321'})('flickr.photos.getInfo') | ||
.use(require('flickrSDK/oauth')({ | ||
accessToken: '123', | ||
accessTokenSecret: '456', | ||
apiSecret: '54321' | ||
})) | ||
.then(function (res) { | ||
// get the photo data off res | ||
**Example** *(Authenticate as a user with the OAuth plugin)* | ||
```js | ||
var flickr = new Flickr(Flickr.OAuth.createPlugin( | ||
process.env.FLICKR_CONSUMER_KEY, | ||
process.env.FLICKR_CONSUMER_SECRET, | ||
process.env.FLICKR_OAUTH_TOKEN, | ||
process.env.FLICKR_OAUTH_TOKEN_SECRET | ||
)); | ||
flickr.test.login().then(function (res) { | ||
console.log('yay!', res.body); | ||
}).catch(function (err) { | ||
console.error('bonk', err); | ||
}); | ||
``` | ||
<a name="Flickr.OAuth"></a> | ||
## troubleshooting | ||
### Flickr.OAuth | ||
**Kind**: static class of [<code>Flickr</code>](#Flickr) | ||
##### ReferenceError: Promise is not defined | ||
* [.OAuth](#Flickr.OAuth) | ||
* [new OAuth(consumerKey, consumerSecret)](#new_Flickr.OAuth_new) | ||
* _instance_ | ||
* [.request(oauthCallback)](#Flickr.OAuth+request) ⇒ <code>Request</code> | ||
* [.authorizeUrl(requestToken, [perms])](#Flickr.OAuth+authorizeUrl) ⇒ <code>String</code> | ||
* [.verify(oauthToken, oauthVerifier, tokenSecret)](#Flickr.OAuth+verify) ⇒ <code>Request</code> | ||
* [.plugin(oauthToken, oauthTokenSecret)](#Flickr.OAuth+plugin) ⇒ <code>function</code> | ||
* _static_ | ||
* [.createPlugin(consumerKey, consumerSecret, oauthToken, oauthTokenSecret)](#Flickr.OAuth.createPlugin) ⇒ <code>function</code> | ||
superagent's Promise support assumes a Promise implementation is available globally. If you are using node 0.10, you will have to polyfill the global Promise manually. | ||
<a name="new_Flickr.OAuth_new"></a> | ||
## license | ||
#### new OAuth(consumerKey, consumerSecret) | ||
Creates a new OAuth service instance. You can use this service to | ||
request and validate OAuth tokens, as well as generate an auth | ||
plugin suitable for use with the REST and Upload services. | ||
You need to [register an application](https://www.flickr.com/services/apps/create/) | ||
to obtain your `consumerKey` and `consumerSecret`. | ||
> **OAuth 1.0 requires your consumer secret to sign calls, | ||
> and you should never expose secrets to the browser.** | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| consumerKey | <code>String</code> | The application's API key | | ||
| consumerSecret | <code>String</code> | The application's API secret | | ||
**Example** | ||
```js | ||
var oauth = new Flickr.OAuth( | ||
process.env.FLICKR_CONSUMER_KEY, | ||
process.env.FLICKR_CONSUMER_SECRET | ||
); | ||
``` | ||
<a name="Flickr.OAuth+request"></a> | ||
#### oAuth.request(oauthCallback) ⇒ <code>Request</code> | ||
Get a Request Token using the consumer key. | ||
**Kind**: instance method of [<code>OAuth</code>](#Flickr.OAuth) | ||
**See** | ||
- https://github.com/visionmedia/superagent | ||
- https://www.flickr.com/services/api/auth.oauth.html#request_token | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| oauthCallback | <code>String</code> | Your application's OAuth callback URL | | ||
**Example** | ||
```js | ||
oauth.request('http://localhost:3000/oauth/callback').then(function (res) { | ||
console.log('yay!', res); | ||
}).catch(function (err) { | ||
console.error('bonk', err); | ||
}); | ||
``` | ||
<a name="Flickr.OAuth+authorizeUrl"></a> | ||
#### oAuth.authorizeUrl(requestToken, [perms]) ⇒ <code>String</code> | ||
Returns the authorization url for `requestToken`. You may also pass | ||
the `perms` your app is requesting as `read` (the default), `write`, | ||
or `delete`. Your application should redirect the user here to ask | ||
them to verify your request token. | ||
**Kind**: instance method of [<code>OAuth</code>](#Flickr.OAuth) | ||
**See**: https://www.flickr.com/services/api/auth.oauth.html#authorization | ||
| Param | Type | Default | Description | | ||
| --- | --- | --- | --- | | ||
| requestToken | <code>String</code> | | The OAuth request token | | ||
| [perms] | <code>String</code> | <code>read</code> | Permission level, may be "read", "write" or "delete" | | ||
**Example** | ||
```js | ||
var url = oauth.authorizeUrl(requestToken); // "https://www.flickr.com/services/oauth..." | ||
res.setHeader("Location", url); | ||
res.statusCode = 302; | ||
res.end(); | ||
``` | ||
<a name="Flickr.OAuth+verify"></a> | ||
#### oAuth.verify(oauthToken, oauthVerifier, tokenSecret) ⇒ <code>Request</code> | ||
Verify an OAuth token using the verifier and token secret. If your user | ||
has indeed verified your request token, you will receive an OAuth token | ||
and secret back, as well as some very basic profile information. You | ||
can now use this token and secret to make calls to the REST API. | ||
**Kind**: instance method of [<code>OAuth</code>](#Flickr.OAuth) | ||
**See** | ||
- https://github.com/visionmedia/superagent | ||
- https://www.flickr.com/services/api/auth.oauth.html#access_token | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| oauthToken | <code>String</code> | The OAuth token to verify | | ||
| oauthVerifier | <code>String</code> | The OAuth token verifier string you received from the callback | | ||
| tokenSecret | <code>String</code> | The OAuth token secret | | ||
**Example** | ||
```js | ||
oauth.verify(oauthToken, oauthVerifier, tokenSecret).then(function (res) { | ||
console.log('oauth token:', res.body.oauth_token); | ||
console.log('oauth token secret:', res.body.oauth_token_secret); | ||
}).catch(function (err) { | ||
console.log('bonk', err); | ||
}); | ||
``` | ||
<a name="Flickr.OAuth+plugin"></a> | ||
#### oAuth.plugin(oauthToken, oauthTokenSecret) ⇒ <code>function</code> | ||
Returns an oauth plugin for this consumer key and secret. | ||
**Kind**: instance method of [<code>OAuth</code>](#Flickr.OAuth) | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| oauthToken | <code>String</code> | The OAuth token | | ||
| oauthTokenSecret | <code>String</code> | The OAuth token secret | | ||
**Example** | ||
```js | ||
var flickr = new Flickr(oauth.plugin( | ||
oauthToken, | ||
oauthTokenSecret | ||
)); | ||
``` | ||
<a name="Flickr.OAuth.createPlugin"></a> | ||
#### OAuth.createPlugin(consumerKey, consumerSecret, oauthToken, oauthTokenSecret) ⇒ <code>function</code> | ||
Returns an oauth plugin for this consumer key, consumer secret, | ||
oauth token and oauth token secret, | ||
**Kind**: static method of [<code>OAuth</code>](#Flickr.OAuth) | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| consumerKey | <code>String</code> | The application's API key | | ||
| consumerSecret | <code>String</code> | The application's API secret | | ||
| oauthToken | <code>String</code> | The OAuth token | | ||
| oauthTokenSecret | <code>String</code> | The OAuth token secret | | ||
**Example** | ||
```js | ||
var flickr = new Flickr(Flickr.OAuth.createPlugin( | ||
process.env.FLICKR_CONSUMER_KEY, | ||
process.env.FLICKR_CONSUMER_SECRET, | ||
process.env.FLICKR_OAUTH_TOKEN, | ||
process.env.FLICKR_OAUTH_TOKEN_SECRET | ||
)); | ||
``` | ||
<a name="Flickr.Upload"></a> | ||
### Flickr.Upload ⇐ <code>Request</code> | ||
**Kind**: static class of [<code>Flickr</code>](#Flickr) | ||
**Extends**: <code>Request</code> | ||
**See**: https://www.flickr.com/services/api/upload.api.html | ||
<a name="new_Flickr.Upload_new"></a> | ||
#### new Upload(auth, file, [args]) | ||
Creates a new Upload service instance. Since the Upload API only | ||
does one thing (upload files), an Upload instance is simply | ||
a Request subclass. | ||
The Upload endpoint requires authentication. You should pass a configured | ||
instance of the [OAuth plugin](#Flickr.OAuth.createPlugin) to upload | ||
photos on behalf of another user. | ||
| Param | Type | | ||
| --- | --- | | ||
| auth | <code>function</code> | | ||
| file | <code>String</code> \| <code>fs.ReadStream</code> \| <code>Buffer</code> | | ||
| [args] | <code>Object</code> | | ||
**Example** | ||
```js | ||
var upload = new Flickr.Upload(auth, 'upload.png', { | ||
title: 'Works on MY machine!' | ||
}); | ||
upload.then(function (res) { | ||
console.log('yay!', res.body); | ||
}).catch(function (err) { | ||
console.error('bonk', err); | ||
}); | ||
``` | ||
<a name="Flickr.Replace"></a> | ||
### Flickr.Replace ⇐ <code>Request</code> | ||
**Kind**: static class of [<code>Flickr</code>](#Flickr) | ||
**Extends**: <code>Request</code> | ||
**See**: https://www.flickr.com/services/api/replace.api.html | ||
<a name="new_Flickr.Replace_new"></a> | ||
#### new Replace(auth, photoID, file, [args]) | ||
Creates a new Replace service instance. Since the Replace API only | ||
does one thing (replace files), an Replace instance is simply | ||
a Request subclass. | ||
The Replace endpoint requires authentication. You should pass a configured | ||
instance of the [OAuth plugin](#Flickr.OAuth.createPlugin) to replace | ||
photos on behalf of another user. | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| auth | <code>function</code> | | | ||
| photoID | <code>Number</code> \| <code>String</code> | The ID of the photo to replace | | ||
| file | <code>String</code> \| <code>fs.ReadStream</code> \| <code>Buffer</code> | | | ||
| [args] | <code>Object</code> | | | ||
**Example** | ||
```js | ||
var replace = new Flickr.Replace(auth, 41234567890, 'replace.png', { | ||
title: 'Now in pink!' | ||
}); | ||
replace.then(function (res) { | ||
console.log('yay!', res.body); | ||
}).catch(function (err) { | ||
console.error('bonk', err); | ||
}); | ||
``` | ||
<a name="Flickr.Feeds"></a> | ||
### Flickr.Feeds | ||
**Kind**: static class of [<code>Flickr</code>](#Flickr) | ||
* [.Feeds](#Flickr.Feeds) | ||
* [new Feeds([args])](#new_Flickr.Feeds_new) | ||
* [.publicPhotos([args])](#Flickr.Feeds+publicPhotos) ⇒ <code>Request</code> | ||
* [.friendsPhotos(args)](#Flickr.Feeds+friendsPhotos) ⇒ <code>Request</code> | ||
* [.favePhotos(args)](#Flickr.Feeds+favePhotos) ⇒ <code>Request</code> | ||
* [.groupDiscussions(args)](#Flickr.Feeds+groupDiscussions) ⇒ <code>Request</code> | ||
* [.groupPool(args)](#Flickr.Feeds+groupPool) ⇒ <code>Request</code> | ||
* [.forum([args])](#Flickr.Feeds+forum) ⇒ <code>Request</code> | ||
* [.recentActivity(args)](#Flickr.Feeds+recentActivity) ⇒ <code>Request</code> | ||
* [.recentComments(args)](#Flickr.Feeds+recentComments) ⇒ <code>Request</code> | ||
<a name="new_Flickr.Feeds_new"></a> | ||
#### new Feeds([args]) | ||
Creates a new Feeds service instance. You can use this instance | ||
to explore and retrieve public Flickr API data. | ||
| Param | Type | Default | Description | | ||
| --- | --- | --- | --- | | ||
| [args] | <code>Object</code> | | Arguments that will be passed along with every feed request | | ||
| [args.format] | <code>String</code> | <code>json</code> | The feed response format | | ||
| [args.lang] | <code>String</code> | <code>en-us</code> | The language to request for the feed | | ||
**Example** | ||
```js | ||
var feeds = new Flickr.Feeds(); | ||
``` | ||
<a name="Flickr.Feeds+publicPhotos"></a> | ||
#### feeds.publicPhotos([args]) ⇒ <code>Request</code> | ||
Returns a list of public content matching some criteria. | ||
**Kind**: instance method of [<code>Feeds</code>](#Flickr.Feeds) | ||
**See**: https://www.flickr.com/services/feeds/docs/photos_public/ | ||
| Param | Type | | ||
| --- | --- | | ||
| [args] | <code>Object</code> | | ||
<a name="Flickr.Feeds+friendsPhotos"></a> | ||
#### feeds.friendsPhotos(args) ⇒ <code>Request</code> | ||
Returns a list of public content from the contacts, friends & family of a given person. | ||
**Kind**: instance method of [<code>Feeds</code>](#Flickr.Feeds) | ||
**See**: https://www.flickr.com/services/feeds/docs/photos_friends/ | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| args | <code>Object</code> | | | ||
| args.user_id | <code>Number</code> \| <code>String</code> | The user ID of the user to fetch friends' photos and videos for. | | ||
<a name="Flickr.Feeds+favePhotos"></a> | ||
#### feeds.favePhotos(args) ⇒ <code>Request</code> | ||
Returns a list of public favorites for a given user. | ||
**Kind**: instance method of [<code>Feeds</code>](#Flickr.Feeds) | ||
**See**: https://www.flickr.com/services/feeds/docs/photos_faves/ | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| args | <code>Object</code> | | | ||
| args.id | <code>Number</code> \| <code>String</code> | A single user ID. This specifies a user to fetch for. | | ||
<a name="Flickr.Feeds+groupDiscussions"></a> | ||
#### feeds.groupDiscussions(args) ⇒ <code>Request</code> | ||
Returns a list of recent discussions in a given group. | ||
**Kind**: instance method of [<code>Feeds</code>](#Flickr.Feeds) | ||
**See**: https://www.flickr.com/services/feeds/docs/groups_discuss/ | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| args | <code>Object</code> | | | ||
| args.id | <code>Number</code> | The ID of the group to fetch discussions for. | | ||
<a name="Flickr.Feeds+groupPool"></a> | ||
#### feeds.groupPool(args) ⇒ <code>Request</code> | ||
Returns a list of things recently added to the pool of a given group. | ||
**Kind**: instance method of [<code>Feeds</code>](#Flickr.Feeds) | ||
**See**: https://www.flickr.com/services/feeds/docs/groups_pool/ | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| args | <code>Object</code> | | | ||
| args.id | <code>Number</code> | The ID of the group to fetch for. | | ||
<a name="Flickr.Feeds+forum"></a> | ||
#### feeds.forum([args]) ⇒ <code>Request</code> | ||
Returns a list of recent topics from the forum. | ||
**Kind**: instance method of [<code>Feeds</code>](#Flickr.Feeds) | ||
**See**: https://www.flickr.com/services/feeds/docs/forums/ | ||
| Param | Type | | ||
| --- | --- | | ||
| [args] | <code>Object</code> | | ||
<a name="Flickr.Feeds+recentActivity"></a> | ||
#### feeds.recentActivity(args) ⇒ <code>Request</code> | ||
Returns a list of recent comments on photostream and sets belonging to a given user. | ||
**Kind**: instance method of [<code>Feeds</code>](#Flickr.Feeds) | ||
**See**: https://www.flickr.com/services/feeds/docs/activity/ | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| args | <code>Object</code> | | | ||
| args.user_id | <code>Number</code> \| <code>String</code> | The user ID to fetch recent activity for. | | ||
<a name="Flickr.Feeds+recentComments"></a> | ||
#### feeds.recentComments(args) ⇒ <code>Request</code> | ||
Returns a list of recent comments that have been commented on by a given person. | ||
**Kind**: instance method of [<code>Feeds</code>](#Flickr.Feeds) | ||
**See**: https://www.flickr.com/services/feeds/docs/photos_comments/ | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| args | <code>Object</code> | | | ||
| args.user_id | <code>Number</code> \| <code>String</code> | The user ID to fetch recent comments for. | | ||
## License | ||
Code licensed under the MIT license. See LICENSE file for terms. | ||
[api keys]: https://www.flickr.com/services/api/misc.api_keys.html | ||
[services/api]: https://www.flickr.com/services/api/ | ||
[services/oauth]: https://www.flickr.com/services/api/auth.oauth.html | ||
[services/feeds]: https://www.flickr.com/services/feeds/ | ||
[services/upload]: https://www.flickr.com/services/api/upload.api.html | ||
[services/replace]: https://www.flickr.com/services/api/replace.api.html | ||
[flickr.photos.getInfo]: https://www.flickr.com/services/api/flickr.photos.getInfo.html | ||
[flickr.photos.search]: https://www.flickr.com/services/api/flickr.photos.search.html | ||
[superagent]: https://github.com/visionmedia/superagent/ |
@@ -1,57 +0,40 @@ | ||
var request = require('superagent'); | ||
var crypto = require('crypto'); | ||
/** | ||
* Returns the HMAC-SHA1 digest of `text` and `key` in baset64 encoding. | ||
* @param {String} text | ||
* @param {String} key | ||
* @returns {String} | ||
* @see https://oauth.net/core/1.0a/#rfc.section.9.2 | ||
* @private | ||
/*! | ||
* Copyright 2017 Yahoo Holdings. | ||
* Licensed under the terms of the MIT license. Please see LICENSE file in the project root for terms. | ||
*/ | ||
function hmac(text, key) { | ||
return crypto.createHmac('sha1', key).update(text).digest('base64'); | ||
} | ||
var request = require('../lib/request'); | ||
var oauth = require('../plugins/oauth'); | ||
/** | ||
* Encodes each of the strings in `arr` and joins them with the '&' | ||
* character (ASCII code 38). | ||
* @param {String[]} arr | ||
* @returns {String} | ||
* @see https://oauth.net/core/1.0a/#rfc.section.9.1.3 | ||
* @see https://oauth.net/core/1.0a/#encoding_parameters | ||
* @private | ||
* Creates a new OAuth service instance. You can use this service to | ||
* request and validate OAuth tokens, as well as generate an auth | ||
* plugin suitable for use with the REST and Upload services. | ||
* | ||
* You need to [register an application](https://www.flickr.com/services/apps/create/) | ||
* to obtain your `consumerKey` and `consumerSecret`. | ||
* | ||
* > **OAuth 1.0 requires your consumer secret to sign calls, | ||
* > and you should never expose secrets to the browser.** | ||
* | ||
* @class | ||
* @param {String} consumerKey - The application's API key | ||
* @param {String} consumerSecret - The application's API secret | ||
* @memberof Flickr | ||
* | ||
* @example | ||
* | ||
* var oauth = new Flickr.OAuth( | ||
* process.env.FLICKR_CONSUMER_KEY, | ||
* process.env.FLICKR_CONSUMER_SECRET | ||
* ); | ||
*/ | ||
function join(arr) { | ||
return arr.map(encodeURIComponent).join('&'); | ||
} | ||
function OAuth(consumerKey, consumerSecret) { | ||
/** | ||
* Normalizes and sorts all of the query string params in `req`, | ||
* then joins them with the '&' character (ASCII code 38). | ||
* @param {Request} | ||
* @returns String. | ||
* @see https://oauth.net/core/1.0a/#sig_norm_param | ||
* @private | ||
*/ | ||
// allow creating a client without `new` | ||
if (!(this instanceof OAuth)) { | ||
return new OAuth(consumerKey, consumerSecret); | ||
} | ||
function query(req) { | ||
var pairs = req.qsRaw.slice(); | ||
Object.keys(req.qs).forEach(function (key) { | ||
pairs.push(key + '=' + encodeURIComponent(req.qs[key])); | ||
}); | ||
return pairs.sort().join('&'); | ||
} | ||
/** | ||
* @constructor | ||
* @param {String} consumerKey The application's API key | ||
* @param {String} consumerSecret The application's API secret | ||
*/ | ||
function OAuth(consumerKey, consumerSecret) { | ||
if (!consumerKey) { | ||
@@ -63,2 +46,3 @@ throw new Error('Missing required argument "consumerKey"'); | ||
} | ||
this.consumerKey = consumerKey; | ||
@@ -69,11 +53,15 @@ this.consumerSecret = consumerSecret; | ||
/** | ||
* @module services/oauth | ||
*/ | ||
module.exports = OAuth; | ||
/** | ||
* Get a Request Token using the consumer key. | ||
* @param {String} oauthCallback | ||
* | ||
* @param {String} oauthCallback - Your application's OAuth callback URL | ||
* @returns {Request} | ||
* | ||
* @example | ||
* | ||
* oauth.request('http://localhost:3000/oauth/callback').then(function (res) { | ||
* console.log('yay!', res); | ||
* }).catch(function (err) { | ||
* console.error('bonk', err); | ||
* }); | ||
* | ||
* @see https://github.com/visionmedia/superagent | ||
@@ -85,6 +73,5 @@ * @see https://www.flickr.com/services/api/auth.oauth.html#request_token | ||
return request('GET', 'https://www.flickr.com/services/oauth/request_token') | ||
.query({ oauth_callback: oauthCallback }) | ||
.query(this.params()) | ||
.parse(this.parse) | ||
.use(this.sign()); | ||
.query({ oauth_callback: oauthCallback }) | ||
.parse(this.parse) | ||
.use(oauth(this.consumerKey, this.consumerSecret, false, false)); | ||
@@ -98,7 +85,57 @@ /* | ||
/** | ||
* Verify an OAuth token using the verifier and token secret. | ||
* @param {String} oauthToken | ||
* @param {String} oauthVerifier | ||
* @param {String} tokenSecret | ||
* Returns the authorization url for `requestToken`. You may also pass | ||
* the `perms` your app is requesting as `read` (the default), `write`, | ||
* or `delete`. Your application should redirect the user here to ask | ||
* them to verify your request token. | ||
* | ||
* @param {String} requestToken - The OAuth request token | ||
* @param {String} [perms=read] - Permission level, may be "read", "write" or "delete" | ||
* @returns {String} | ||
* | ||
* @example | ||
* | ||
* var url = oauth.authorizeUrl(requestToken); // "https://www.flickr.com/services/oauth..." | ||
* | ||
* res.setHeader("Location", url); | ||
* res.statusCode = 302; | ||
* res.end(); | ||
* | ||
* @see https://www.flickr.com/services/api/auth.oauth.html#authorization | ||
*/ | ||
OAuth.prototype.authorizeUrl = function (requestToken, perms) { | ||
if (typeof perms !== 'string') { | ||
perms = 'read'; | ||
} | ||
switch (perms) { | ||
case 'read': | ||
case 'write': | ||
case 'delete': | ||
return 'https://www.flickr.com/services/oauth/authorize?perms=' + perms + '&oauth_token=' + encodeURIComponent(requestToken); | ||
default: | ||
throw new Error('Unknown oauth perms "' + perms + '"'); | ||
} | ||
}; | ||
/** | ||
* Verify an OAuth token using the verifier and token secret. If your user | ||
* has indeed verified your request token, you will receive an OAuth token | ||
* and secret back, as well as some very basic profile information. You | ||
* can now use this token and secret to make calls to the REST API. | ||
* | ||
* @param {String} oauthToken - The OAuth token to verify | ||
* @param {String} oauthVerifier - The OAuth token verifier string you received from the callback | ||
* @param {String} tokenSecret - The OAuth token secret | ||
* @returns {Request} | ||
* | ||
* @example | ||
* | ||
* oauth.verify(oauthToken, oauthVerifier, tokenSecret).then(function (res) { | ||
* console.log('oauth token:', res.body.oauth_token); | ||
* console.log('oauth token secret:', res.body.oauth_token_secret); | ||
* }).catch(function (err) { | ||
* console.log('bonk', err); | ||
* }); | ||
* | ||
* @see https://github.com/visionmedia/superagent | ||
@@ -110,6 +147,9 @@ * @see https://www.flickr.com/services/api/auth.oauth.html#access_token | ||
return request('GET', 'https://www.flickr.com/services/oauth/access_token') | ||
.query({ oauth_token: oauthToken, oauth_verifier: oauthVerifier }) | ||
.query(this.params()) | ||
.parse(this.parse) | ||
.use(this.sign(tokenSecret)); | ||
.query({ oauth_verifier: oauthVerifier }) | ||
.parse(this.parse) | ||
.use(oauth(this.consumerKey, this.consumerSecret, oauthToken, tokenSecret)); | ||
/* | ||
TODO hand back a new Flickr instance with the oauth plugin set up? | ||
*/ | ||
}; | ||
@@ -123,2 +163,3 @@ | ||
* @type {Function} | ||
* @private | ||
*/ | ||
@@ -129,53 +170,51 @@ | ||
/** | ||
* Returns the number of seconds since January 1, 1970 00:00:00 GMT. | ||
* @returns {Number} | ||
* @see https://oauth.net/core/1.0a/#nonce | ||
* Returns an oauth plugin for this consumer key and secret. | ||
* | ||
* @param {String} oauthToken - The OAuth token | ||
* @param {String} oauthTokenSecret - The OAuth token secret | ||
* @returns {Function} | ||
* | ||
* @example | ||
* | ||
* var flickr = new Flickr(oauth.plugin( | ||
* oauthToken, | ||
* oauthTokenSecret | ||
* )); | ||
*/ | ||
OAuth.prototype.timestamp = function () { | ||
return Math.floor(Date.now() / 1000); | ||
OAuth.prototype.plugin = function (oauthToken, oauthTokenSecret) { | ||
return oauth(this.consumerKey, this.consumerSecret, oauthToken, oauthTokenSecret); | ||
}; | ||
/** | ||
* Generates a pseudo-random string. OAuth 1.0 defines a | ||
* nonce as a value unique within a given timestamp in seconds. | ||
* @returns {String} | ||
* @see https://oauth.net/core/1.0a/#nonce | ||
* Returns an oauth plugin for this consumer key, consumer secret, | ||
* oauth token and oauth token secret, | ||
* | ||
* @static | ||
* @param {String} consumerKey - The application's API key | ||
* @param {String} consumerSecret - The application's API secret | ||
* @param {String} oauthToken - The OAuth token | ||
* @param {String} oauthTokenSecret - The OAuth token secret | ||
* @returns {Function} | ||
* | ||
* @example | ||
* | ||
* var flickr = new Flickr(Flickr.OAuth.createPlugin( | ||
* process.env.FLICKR_CONSUMER_KEY, | ||
* process.env.FLICKR_CONSUMER_SECRET, | ||
* process.env.FLICKR_OAUTH_TOKEN, | ||
* process.env.FLICKR_OAUTH_TOKEN_SECRET | ||
* )); | ||
*/ | ||
OAuth.prototype.nonce = function () { | ||
return crypto.pseudoRandomBytes(32).toString('base64'); | ||
OAuth.createPlugin = function (consumerKey, consumerSecret, oauthToken, oauthTokenSecret) { | ||
return (new this( | ||
consumerKey, | ||
consumerSecret | ||
)).plugin( | ||
oauthToken, | ||
oauthTokenSecret | ||
); | ||
}; | ||
/** | ||
* Creates an object with the standard OAuth 1.0 query params | ||
* for this instance. | ||
* @returns {Object} | ||
*/ | ||
OAuth.prototype.params = function () { | ||
return { | ||
oauth_nonce: this.nonce(), | ||
oauth_timestamp: this.timestamp(), | ||
oauth_consumer_key: this.consumerKey, | ||
oauth_signature_method: 'HMAC-SHA1', | ||
oauth_version: '1.0' | ||
}; | ||
}; | ||
/** | ||
* TODO docs | ||
*/ | ||
OAuth.prototype.sign = function (tokenSecret) { | ||
var consumerSecret = this.consumerSecret; | ||
return function (req) { | ||
var signingKey = join([ consumerSecret, tokenSecret || '' ]); | ||
var baseString = join([ req.method, req.url, query(req) ]); | ||
req.query({ | ||
oauth_signature: hmac(baseString, signingKey) | ||
}); | ||
}; | ||
}; | ||
module.exports = OAuth; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
196141
18
3968
730
0
16
+ Addedxml2js@^0.4.17
+ Addedasynckit@0.4.0(transitive)
+ Addeddebug@3.2.7(transitive)
+ Addedform-data@2.5.2(transitive)
+ Addedms@2.1.3(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedsax@1.4.1(transitive)
+ Addedsuperagent@3.8.3(transitive)
+ Addedxml2js@0.4.23(transitive)
+ Addedxmlbuilder@11.0.1(transitive)
- Removeddeepmerge@^1.1.1
- Removedasync@1.5.2(transitive)
- Removeddebug@2.6.9(transitive)
- Removeddeepmerge@1.5.2(transitive)
- Removedform-data@1.0.0-rc4(transitive)
- Removedms@2.0.0(transitive)
- Removedsuperagent@2.2.0(transitive)
Updatedsuperagent@^3.5.3-beta.2