code: function(provider, options) {
        var authType;
        if (_.isString(provider)) {
          authType = provider;
          provider = Parse.User._authProviders[provider];
        } else {
          authType = provider.getAuthType();
        }
        if (_.has(options, 'authData')) {
          var authData = this.get('authData') || {};
          authData[authType] = options.authData;
          this.set('authData', authData);
  
          // Overridden so that the user can be made the current user.
          var newOptions = _.clone(options) || {};
          newOptions.success = function(model) {
            model._handleSaveResult(true);
            if (options.success) {
              options.success.apply(this, arguments);
            }
          };
          return this.save({'authData': authData}, newOptions);
        } else {
          var self = this;
          var promise = new Parse.Promise();
          provider.authenticate({
            success: function(provider, result) {
              self._linkWith(provider, {
                authData: result,
                success: options.success,
                error: options.error
              }).then(function() {
                promise.resolve(self);
              });
            },
            error: function(provider, error) {
              if (options.error) {
                options.error(self, error);
              }
              promise.reject(error);
            }
          });
          return promise;
        }
      }
docs: Unlike in the Android/iOS SDKs, logInWith is unnecessary, since you can
  call linkWith on the user (even if it doesn't exist yet on the server).