function resolveNext(err, token) {
        if ((!err && token) || index === providers.length) {
          AWS.util.arrayEach(self.resolveCallbacks, function (callback) {
            callback(err, token);
          });
          self.resolveCallbacks.length = 0;
          return;
        }

        var provider = providers[index++];
        if (typeof provider === 'function') {
          token = provider.call();
        } else {
          token = provider;
        }

        if (token.get) {
          token.get(function (getErr) {
            resolveNext(getErr, getErr ? null : token);
          });
        } else {
          resolveNext(null, token);
        }
      }
Resolves the provider chain by searching for the first token in {providers}.

@callback callback function(err, token)
  Called when the provider resolves the chain to a token object
  or null if no token can be found.

  @param err [Error] the error object returned if no token is found.
  @param token [AWS.Token] the token object resolved by the provider chain.
@return [AWS.TokenProviderChain] the provider, for chaining.