lib/passport-dropbox-oauth2/strategy.js
function Strategy(options, verify) {
  var supportedApiVersions = ['1', '2'],
      defaultOptionsByApiVersion = {
        1: {
          authorizationURL: 'https://www.dropbox.com/1/oauth2/authorize',
          tokenURL: 'https://api.dropbox.com/1/oauth2/token',
          scopeSeparator: ',',
          customHeaders: {}
        },
        2: {
          authorizationURL: 'https://www.dropbox.com/oauth2/authorize',
          tokenURL: 'https://api.dropbox.com/oauth2/token',
          scopeSeparator: ',',
          customHeaders: {
            'Content-Type': 'application/json'
          }
        }
      };

  options = options || {};

  if (options.apiVersion != null && supportedApiVersions.indexOf(options.apiVersion.toString()) === -1) {
    throw new Error('Unsupported Dropbox API version. Supported versions are "1" and "2".');
  }

  this._apiVersion = options.apiVersion || '1';

  options.authorizationURL = options.authorizationURL || defaultOptionsByApiVersion[this._apiVersion].authorizationURL;
  options.tokenURL = options.tokenURL || defaultOptionsByApiVersion[this._apiVersion].tokenURL;

  options.scopeSeparator = options.scopeSeparator || defaultOptionsByApiVersion[this._apiVersion].scopeSeparator;
  options.customHeaders = options.customHeaders || defaultOptionsByApiVersion[this._apiVersion].customHeaders;

  OAuth2Strategy.call(this, options, verify);
  this.name = 'dropbox-oauth2';
}
function Strategy(options, verify) {
  var supportedApiVersions = ['1', '2'],
      defaultOptionsByApiVersion = {
        1: {
          authorizationURL: 'https://www.dropbox.com/1/oauth2/authorize',
          tokenURL: 'https://api.dropbox.com/1/oauth2/token',
          scopeSeparator: ',',
          customHeaders: {}
        },
        2: {
          authorizationURL: 'https://www.dropbox.com/oauth2/authorize',
          tokenURL: 'https://api.dropbox.com/oauth2/token',
          scopeSeparator: ',',
          customHeaders: {
            'Content-Type': 'application/json'
          }
        }
      };

  options = options || {};

  if (options.apiVersion != null && supportedApiVersions.indexOf(options.apiVersion.toString()) === -1) {
    throw new Error('Unsupported Dropbox API version. Supported versions are "1" and "2".');
  }

  this._apiVersion = options.apiVersion || '1';

  options.authorizationURL = options.authorizationURL || defaultOptionsByApiVersion[this._apiVersion].authorizationURL;
  options.tokenURL = options.tokenURL || defaultOptionsByApiVersion[this._apiVersion].tokenURL;

  options.scopeSeparator = options.scopeSeparator || defaultOptionsByApiVersion[this._apiVersion].scopeSeparator;
  options.customHeaders = options.customHeaders || defaultOptionsByApiVersion[this._apiVersion].customHeaders;

  OAuth2Strategy.call(this, options, verify);
  this.name = 'dropbox-oauth2';
}
`Strategy` constructor.

The Dropbox authentication strategy authenticates requests by delegating to
Dropbox using the OAuth 2.0 protocol.

Applications must supply a `verify` callback which accepts an `accessToken`,
`refreshToken` and service-specific `profile`, and then calls the `done`
callback supplying a `user`, which should be set to `false` if the
credentials are not valid.  If an exception occurred, `err` should be set.

Options:
- `apiVersion`    (optional) the Dropbox API version to use (either '1' or '2'). Default is '1'.
- `clientID`      your Dropbox application's app key found in the App Console
- `clientSecret`  your Dropbox application's app secret
- `callbackURL`   URL to which Dropbox will redirect the user after granting authorization

Examples:

passport.use(new DropboxStrategy({
clientID: 'yourAppKey',
clientSecret: 'yourAppSecret'
callbackURL: 'https://www.example.net/auth/dropbox-oauth2/callback',
},
function(accessToken, refreshToken, profile, done) {
User.findOrCreate(..., function (err, user) {
done(err, user);
});
}
));

@param {Object} options
@param {Function} verify
@api public