How to use the oauth/oauth_error.OAuthBadRequestError function in oauth

To help you get started, we’ve selected a few oauth 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 christkv / node-express-oauth-plugin / lib / oauth / oauth_services.js View on Github external
self.provider.applicationByConsumerKey(token.consumer_key, function(err, user) {
            if(user.consumer_key == null || user.secret == null) { callback(new errors.OAuthProviderError("provider: applicationByConsumerKey must return a object with fields [token, secret]"), null); return;}
            // If we have a user for this consumer key let's calculate the signature
            var calculatedSignature = self.calculateSignature(method, protocol, url, path, requestParameters, token.token_secret, user.secret);            
            // Check if the signature is correct and return a access token
            if(calculatedSignature == requestParameters.oauth_signature || self.calculateSignatureGoogleWay(method, protocol, url, path, requestParameters, token.token_secret, user.secret) == requestParameters.oauth_signature) {
              // Fetch the user id to pass back
              self.provider.userIdByToken(requestParameters.oauth_token, function(err, doc) {
                if(doc.id == null) { callback(new errors.OAuthProviderError("provider: userIdByToken must return a object with fields [id]"), null); return;}
                // Return the user id to the calling function
                callback(null, doc);                
              });
            } else {
              callback(new errors.OAuthBadRequestError("Invalid signature"), null);
            }          
          });
        }
github christkv / node-express-oauth-plugin / lib / oauth / oauth_services.js View on Github external
OAuthServices.prototype.accessToken = function(method, protocol, url, path, headers, parameters, callback) { 
  var requestParameters = this.parseParameters(headers, parameters);
  if(requestParameters == null) { callback(new errors.OAuthBadRequestError("Missing required parameter"), null); return };

  // Ensure correct parameters are available
  if(!this.validateParameters(requestParameters, ['oauth_consumer_key', 'oauth_token', 'oauth_signature_method', 'oauth_signature', 'oauth_timestamp', 'oauth_nonce', 'oauth_verifier'])) { callback(new errors.OAuthBadRequestError("Missing required parameter")); return };
  var self = this;

  // Fetch the secret and token for the user
  this.provider.applicationByConsumerKey(requestParameters['oauth_consumer_key'], function(err, user) {
    if(err) {
      callback(new errors.OAuthProviderError('Invalid Consumer Key'), null);        
    } else {
      if(user.consumer_key == null || user.secret == null) { callback(new errors.OAuthProviderError("provider: applicationByConsumerKey must return a object with fields [token, secret]"), null); return;}
      // Fetch the secret and token for the user
      self.provider.tokenByConsumer(requestParameters['oauth_consumer_key'], function(err, tokenObject) {
        if(err) {
          callback(new errors.OAuthProviderError('Invalid / expired Token'), null);        
        } else {