diff --git a/README.md b/README.md index 9913766..b5b37ce 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,8 @@ The SoundCloud authentication strategy authenticates users using a SoundCloud ac The strategy requires a `verify` callback, which accepts these credentials and calls `next` providing a user, as well as `options` specifying a app ID and app secret. ```javascript +var SoundCloudTokenStrategy = require('passport-soundcloud-token'); + passport.use(new SoundCloudTokenStrategy({ clientID: SOUND_CLOUD_CLIENT_ID, clientSecret: SOUND_CLOUD_CLIENT_SECRET, diff --git a/package.json b/package.json index c14b6f3..aaf747d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "passport-soundcloud-token", - "version": "2.0.0", + "version": "2.0.1", "description": "Passport strategy for authenticating with SoundCloud via OAuth2 access tokens", "main": "lib/index.js", "scripts": { @@ -25,6 +25,9 @@ "url": "https://github.com/ghaiklor/passport-soundcloud-token/issues" }, "homepage": "https://github.com/ghaiklor/passport-soundcloud-token", + "dependencies": { + "passport-oauth": "1.0.0" + }, "devDependencies": { "babel": "5.8.23", "chai": "2.3.0", @@ -32,8 +35,5 @@ "istanbul": "0.3.21", "mocha": "2.3.3", "sinon": "1.17.1" - }, - "dependencies": { - "passport-oauth": "1.0.0" } } diff --git a/src/index.js b/src/index.js index 3f136c7..249019e 100644 --- a/src/index.js +++ b/src/index.js @@ -12,21 +12,17 @@ import { OAuth2Strategy, InternalOAuthError } from 'passport-oauth'; * - clientSecret Secret used to establish ownership of the consumer key * - passReqToCallback If need, pass req to verify callback * - * Example: - * passport.use(new SoundCloudTokenStrategy({ - * clientID: '123-456-789', - * clientSecret: 'shhh-its-a-secret', - * passReqToCallback: true - * }, function(req, accessToken, refreshToken, profile, next) { - * User.findOrCreate(..., function (error, user) { - * next(error, user); - * }); - * } - * )); - * * @param {Object} _options * @param {Function} _verify - * @constructor + * @example + * passport.use(new SoundCloudTokenStrategy({ + * clientID: '123456789', + * clientSecret: 'shhh-its-a-secret' + * }), function(req, accessToken, refreshToken, profile, next) { + * User.findOrCreate({soundCloudId: profile.id}, function(error, user) { + * next(error, user); + * }) + * }) */ export default class SoundCloudTokenStrategy extends OAuth2Strategy { constructor(_options, _verify) { @@ -43,7 +39,8 @@ export default class SoundCloudTokenStrategy extends OAuth2Strategy { this._refreshTokenField = options.refreshTokenField || 'refresh_token'; this._profileURL = options.profileURL || 'https://api.soundcloud.com/me.json'; this._passReqToCallback = options.passReqToCallback; - this._oauth2._useAuthorizationHeaderForGET = true; + + this._oauth2.useAuthorizationHeaderforGET(true); } /**