Skip to content

Commit

Permalink
General improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
ghaiklor committed Oct 3, 2015
1 parent be9fc57 commit b9585a1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand All @@ -25,15 +25,15 @@
"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",
"chai-passport-strategy": "0.2.0",
"istanbul": "0.3.21",
"mocha": "2.3.3",
"sinon": "1.17.1"
},
"dependencies": {
"passport-oauth": "1.0.0"
}
}
25 changes: 11 additions & 14 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
}

/**
Expand Down

0 comments on commit b9585a1

Please sign in to comment.