How to use passport-oauth1 - 10 common examples

To help you get started, we’ve selected a few passport-oauth1 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aredotna / ervell / node_modules / arena-passport / node_modules / passport-twitter / lib / strategy.js View on Github external
Strategy.prototype.authenticate = function(req, options) {
  // When a user denies authorization on Twitter, they are presented with a link
  // to return to the application in the following format (where xxx is the
  // value of the request token):
  //
  //     http://www.example.com/auth/twitter/callback?denied=xxx
  //
  // Following the link back to the application is interpreted as an
  // authentication failure.
  if (req.query && req.query.denied) {
    return this.fail();
  }
  
  // Call the base class for standard OAuth authentication.
  OAuthStrategy.prototype.authenticate.call(this, req, options);
};
github jaredhanson / passport-twitter / lib / strategy.js View on Github external
Strategy.prototype.authenticate = function(req, options) {
  // When a user denies authorization on Twitter, they are presented with a link
  // to return to the application in the following format (where xxx is the
  // value of the request token):
  //
  //     http://www.example.com/auth/twitter/callback?denied=xxx
  //
  // Following the link back to the application is interpreted as an
  // authentication failure.
  if (req.query && req.query.denied) {
    return this.fail();
  }
  
  // Call the base class for standard OAuth authentication.
  OAuthStrategy.prototype.authenticate.call(this, req, options);
};
github jaredhanson / passport-twitter / lib / strategy.js View on Github external
this._oauth.get(uri.format(url), token, tokenSecret, function (err, body, res) {
      if (err) {
        if (err.data) {
          try {
            json = JSON.parse(err.data);
          } catch (_) {}
        }
        
        if (json && json.errors && json.errors.length) {
          var e = json.errors[0];
          return done(new APIError(e.message, e.code));
        }
        return done(new InternalOAuthError('Failed to fetch user profile', err));
      }
      
      try {
        json = JSON.parse(body);
      } catch (ex) {
        return done(new Error('Failed to parse user profile'));
      }
      
      var profile = Profile.parse(json);
      profile.provider = 'twitter';
      profile._raw = body;
      profile._json = json;
      // NOTE: The "X-Access-Level" header is described here:
      //       https://dev.twitter.com/oauth/overview/application-permission-model
      //       https://dev.twitter.com/oauth/overview/application-permission-model-faq
      profile._accessLevel = res.headers['x-access-level'];
github alarner / perk / lib / auth / adapters / trello.js View on Github external
function TrelloStrategy(options, verify) {
	OAuth1Strategy.call(this, Object.assign({
		requestTokenURL: 'https://trello.com/1/OAuthGetRequestToken',
		accessTokenURL: 'https://trello.com/1/OAuthGetAccessToken',
		userAuthorizationURL: 'https://trello.com/1/OAuthAuthorizeToken',
		sessionKey: 'trello',
		consumerKey: options.clientID,
		consumerSecret: options.clientSecret
	}, options), (req, accessToken, refreshToken, profile, done) => {
		request(`https://api.trello.com/1/members/me?key=${options.clientID}&token=${accessToken}`,
			(err, response, body) => {
				if (err) return done(err);
				const profile = JSON.parse(body);
				const namePieces = profile.fullName.split(' ');
				const result = { id: profile.id };
				result[config.auth.columns.user.firstName] = namePieces.shift();
				result[config.auth.columns.user.lastName] = namePieces.join(' ');
				result[config.auth.columns.user.email] = null;
github TIY-Austin-Front-End-Engineering / Curriculum / notes / day-38 / examples / breadcrumbs / lib / auth / adapters / trello.js View on Github external
function TrelloStrategy(options, verify) {
	options = options || {};
	options.requestTokenURL = options.requestTokenURL || 'https://trello.com/1/OAuthGetRequestToken';
	options.accessTokenURL = options.accessTokenURL || 'https://trello.com/1/OAuthGetAccessToken';
	options.userAuthorizationURL = options.userAuthorizationURL || 'https://trello.com/1/OAuthAuthorizeToken';
	options.sessionKey = options.sessionKey || 'trello';

	OAuth1Strategy.call(this, options, (req, accessToken, refreshToken, profile, done) => {
		request(
			'https://api.trello.com/1/members/me?key='+options.consumerKey+'&token='+accessToken,
			function (error, response, body) {
				if(error) {
					return done(error);
				}
				var profile = JSON.parse(body);
				var namePieces = profile.fullName.split(' ');
				verify(req, accessToken, refreshToken, {
					id: profile.id,
					firstName: namePieces.shift(),
					lastName: namePieces.join(' '),
					email: null
				}, done);
			}
		);
github TIY-Austin-Front-End-Engineering / Curriculum / notes / day-38 / examples / breadcrumbs / lib / auth / adapters / trello.js View on Github external
return done(error);
				}
				var profile = JSON.parse(body);
				var namePieces = profile.fullName.split(' ');
				verify(req, accessToken, refreshToken, {
					id: profile.id,
					firstName: namePieces.shift(),
					lastName: namePieces.join(' '),
					email: null
				}, done);
			}
		);
	});
	this.name = 'trello';
};
TrelloStrategy.prototype = OAuth1Strategy.prototype;


module.exports = {
	translateProfile: (token, tokenSecret, profile, cb) => { cb(null, profile); },
	strategy: TrelloStrategy
};
github alarner / perk / lib / auth / adapters / trello.js View on Github external
request(`https://api.trello.com/1/members/me?key=${options.clientID}&token=${accessToken}`,
			(err, response, body) => {
				if (err) return done(err);
				const profile = JSON.parse(body);
				const namePieces = profile.fullName.split(' ');
				const result = { id: profile.id };
				result[config.auth.columns.user.firstName] = namePieces.shift();
				result[config.auth.columns.user.lastName] = namePieces.join(' ');
				result[config.auth.columns.user.email] = null;
				verify(req, accessToken, refreshToken, result, done);
			}
		);
	});
	this.name = 'trello';
};
TrelloStrategy.prototype = Object.create(OAuth1Strategy.prototype);


module.exports = {
	translateProfile: (token, tokenSecret, profile, cb) => { cb(null, profile); },
	strategy: TrelloStrategy,
	packageName: 'passport-oauth1'
};
github jaredhanson / passport-evernote / lib / strategy.js View on Github external
function Strategy(options, verify) {
  options = options || {};
  options.requestTokenURL = options.requestTokenURL || 'https://www.evernote.com/oauth';
  options.accessTokenURL = options.accessTokenURL || 'https://www.evernote.com/oauth';
  options.userAuthorizationURL = options.userAuthorizationURL || 'https://www.evernote.com/OAuth.action';
  options.sessionKey = options.sessionKey || 'oauth:evernote';
  
  OAuthStrategy.call(this, options, verify);
  this.name = 'evernote';
}
github jaredhanson / passport-dropbox / lib / strategy.js View on Github external
function Strategy(options, verify) {
  options = options || {};
  options.requestTokenURL = options.requestTokenURL || 'https://api.dropbox.com/1/oauth/request_token';
  options.accessTokenURL = options.accessTokenURL || 'https://api.dropbox.com/1/oauth/access_token';
  var params = { oauth_callback: options.callbackURL };
  options.userAuthorizationURL = options.userAuthorizationURL || 'https://www.dropbox.com/1/oauth/authorize?' + querystring.stringify(params);
  options.sessionKey = options.sessionKey || 'oauth:dropbox';

  OAuthStrategy.call(this, options, verify);
  this.name = 'dropbox';
}
github jaredhanson / passport-twitter / lib / strategy.js View on Github external
function Strategy(options, verify) {
  options = options || {};
  options.requestTokenURL = options.requestTokenURL || 'https://api.twitter.com/oauth/request_token';
  options.accessTokenURL = options.accessTokenURL || 'https://api.twitter.com/oauth/access_token';
  options.userAuthorizationURL = options.userAuthorizationURL || 'https://api.twitter.com/oauth/authenticate';
  options.sessionKey = options.sessionKey || 'oauth:twitter';
  
  OAuthStrategy.call(this, options, verify);
  this.name = 'twitter';
  this._userProfileURL = options.userProfileURL || 'https://api.twitter.com/1.1/account/verify_credentials.json';
  this._skipExtendedUserProfile = (options.skipExtendedUserProfile !== undefined) ? options.skipExtendedUserProfile : false;
  this._includeEmail = (options.includeEmail !== undefined) ? options.includeEmail : false;
  this._includeStatus = (options.includeStatus !== undefined) ? options.includeStatus : true;
  this._includeEntities = (options.includeEntities !== undefined) ? options.includeEntities : true;
}

passport-oauth1

OAuth 1.0 authentication strategy for Passport.

MIT
Latest version published 2 years ago

Package Health Score

50 / 100
Full package analysis