Fixes #396.
This PR is a replacement for #397 that caused a bug in at least one downstream librariy. It contains additional logic that correctly handles timeouts passed as a tuple (the requests library support two different timeout forms - link).
The first commit is identical to the original PR, and all new logic is contained in the commit(s) that follow.
MIND:
A downstream library that is timeout-sensitive might still be affected by the change, because the new explicit timeout parameter changes the semantics of AuthorizedSession.request() . The timeout represents the total allowed time for all requests made behind the scenes (e.g. credentials refresh attempts), as opposed to a previous per-request timeout.
The rationale behind this, however, is that libraries such as BigQuery use AuthorizedSession as their transport, and consider auth_session.request(...) a single operation, even though the latter might consist of multiple requests.
P.S.: On the other hand, and if I read the code correctly, any exiting timeout argument (passed via **kwargs) already applied to the "main" request only, and not to the credentials-related requests. The initial self.credentials.before_request() call had a hard-coded timeout of 120 seconds, while any subsequent credentials refresh calls used self._refresh_timeout, which is actually None by default.