How to use the oauth/crypto/sha1.SHA1 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
OAuthServices.prototype.calculateSignatureGoogleWay = function(method, protocol, url, path, parameters, token, secret) {
  // Create secret key for encryption
  var key = secret + "&" + (token != null ? token : '');
  // Create array of names and sort it
  var values = [];
  for(var name in parameters) { if(name != 'oauth_signature') values.push(name); };
  values = values.sort();
  var concatString = method + "&" + querystring.escape(protocol + "://" + url + path) + "&" + querystring.escape(values.map(function(value) {
    return querystring.escape(value) + "=" + querystring.escape(parameters[value]);
  }, '').join("&"));
  // Calculated signature
  return crypto.SHA1.b64_hmac_sha1(key, concatString) + "=";    
}