<commit_before>var OAuth2Strategy = require('passport-oauth').OAuth2Strategy
  , InternalOAuthError = require('passport-oauth').InternalOAuthError
  , util = require('util');

/**
 * `Strategy` constructor.
 *
 * MailChimp uses the OAuth 2.0 protocol for authentication.
 *
 * Applications using this must supply a callback to verify the credentials which
 * accepts an `accessToken`, `refreshToken`, and a `profile`. After verifying the
 * credentials it should call `done` with the user object and any error that may
 * have occured as the first parameter.
 *
 * Options:
 *   - `clientID`	your MailChimp application's App ID
 *   - `clientSecret`	your MailChimp application's App Secret
 *   - `callbackURL`	URL to which MailChimp will redirect the user after granting authorization
 *
 * Examples:
 *
 *     passport.use(new MailChimpStrategy({
 *         clientID: 'MAILCHIMP_APP_ID',
 *         clientSecret: 'SECRET_SAUCE',
 *         callbackURL: 'https://www.example.net/auth/mailchimp/callback'
 *       },
 *       function(accessToken, refreshToken, profile, done) {
 *         User.findOrCreate(..., function (err, user) {
 *           done(err, user);
 *         });
 *       }
 *     ));
 *
 * @param {Object} options
 * @param {Function} verify
 * @api public
 */
function Strategy(options, verify) {
  options = options || {};
  options.authorizationURL = options.authorizationURL || 'https://login.mailchimp.com/oauth2/authorize';
  options.tokenURL = options.tokenURL || 'https://login.mailchimp.com/oauth2/token';

  OAuth2Strategy.call(this, options, verify);
  this.name = 'mailchimp';
  this._oauth2._useAuthorizationHeaderForGET = true;
}

util.inherits(Strategy, OAuth2Strategy);

Strategy.prototype.authorizationParams = function (options) {
  var params = {}
    , display = options.display;

  if (display) {
    params['display'] = display;
  }

  return params;
}

/**
 * Retrieve user profile from MailChimp.
 *
 * This function constructs a profile from the MailChimp metadata call:
 *
 *   - `provider`	set to `mailchimp`
 *   - `id`		the user's MailChimp ID
 *   - `
 *
 * @param {String} accessToken
 * @param {Function} done
 * @api protected
 */
Strategy.prototype.userProfile = function(accessToken, done) {
  this._oauth2.get('https://login.mailchimp.com/oauth2/metadata', accessToken, function (err, body, res) {
    if (err) {
      return done(new InternalOAuthError('Failed to fetch user metadata', err));
    }

    try {
      var json = JSON.parse(body);<commit_msg>remove authorizationParams since we don't need to set custom ones<commit_after>var OAuth2Strategy = require('passport-oauth').OAuth2Strategy
  , InternalOAuthError = require('passport-oauth').InternalOAuthError
  , util = require('util');

/**
 * `Strategy` constructor.
 *
 * MailChimp uses the OAuth 2.0 protocol for authentication.
 *
 * Applications using this must supply a callback to verify the credentials which
 * accepts an `accessToken`, `refreshToken`, and a `profile`. After verifying the
 * credentials it should call `done` with the user object and any error that may
 * have occured as the first parameter.
 *
 * Options:
 *   - `clientID`	your MailChimp application's App ID
 *   - `clientSecret`	your MailChimp application's App Secret
 *   - `callbackURL`	URL to which MailChimp will redirect the user after granting authorization
 *
 * Examples:
 *
 *     passport.use(new MailChimpStrategy({
 *         clientID: 'MAILCHIMP_APP_ID',
 *         clientSecret: 'SECRET_SAUCE',
 *         callbackURL: 'https://www.example.net/auth/mailchimp/callback'
 *       },
 *       function(accessToken, refreshToken, profile, done) {
 *         User.findOrCreate(..., function (err, user) {
 *           done(err, user);
 *         });
 *       }
 *     ));
 *
 * @param {Object} options
 * @param {Function} verify
 * @api public
 */
function Strategy(options, verify) {
  options = options || {};
  options.authorizationURL = options.authorizationURL || 'https://login.mailchimp.com/oauth2/authorize';
  options.tokenURL = options.tokenURL || 'https://login.mailchimp.com/oauth2/token';

  OAuth2Strategy.call(this, options, verify);
  this.name = 'mailchimp';
  this._oauth2._useAuthorizationHeaderForGET = true;
}

util.inherits(Strategy, OAuth2Strategy);

/**
 * Retrieve user profile from MailChimp.
 *
 * This function constructs a profile from the MailChimp metadata call:
 *
 *   - `provider`	set to `mailchimp`
 *   - `id`		the user's MailChimp ID
 *   - `
 *
 * @param {String} accessToken
 * @param {Function} done
 * @api protected
 */
Strategy.prototype.userProfile = function(accessToken, done) {
  this._oauth2.get('https://login.mailchimp.com/oauth2/metadata', accessToken, function (err, body, res) {
    if (err) {
      return done(new InternalOAuthError('Failed to fetch user metadata', err));
    }

    try {
      var json = JSON.parse(body);
{'fraction_non_alphanumeric': 0.12441170452220177, 'fraction_numerical': 0.004501739308369143, 'mean_word_length': 3.5385329619312906, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 8, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '801028', 'n_tokens_mistral': 1486, 'n_tokens_neox': 1461, 'n_words': 393}