How to use the passport-oauth1.InternalOAuthError function in passport-oauth1

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 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 jaredhanson / passport-dropbox / lib / strategy.js View on Github external
this._oauth.get('https://api.dropbox.com/1/account/info', token, tokenSecret, function (err, body, res) {
    var json;
    
    if (err) {
      if (err.data) {
        try {
          json = JSON.parse(err.data);
        } catch (_) {}
      }
      
      if (json && json.error) {
        return done(new Error(json.error));
      }
      
      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 = 'dropbox';
    profile._raw = body;
    profile._json = json;
    
    done(null, profile);
  });
}
github aredotna / ervell / node_modules / arena-passport / node_modules / passport-twitter / lib / strategy.js View on Github external
this._oauth.get(this._userProfileURL + '?user_id=' + params.user_id, 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 = parse(json);
      profile.provider = 'twitter';
      profile._raw = body;
      profile._json = json;
  
      done(null, profile);
    });
  } else {

passport-oauth1

OAuth 1.0 authentication strategy for Passport.

MIT
Latest version published 1 year ago

Package Health Score

53 / 100
Full package analysis