def refreshed(ignore):
headers = {}
self._credentials.apply(headers)
- return headers['Authorization']
+ result = headers['Authorization']
+ # The value was bytes in oauth2client 1.0, unicode in 1.1, maybe
+ # they'll change it again in 1.2...
+ if isinstance(result, unicode):
+ result = result.encode("ascii")
+ return result
d.addCallback(refreshed)
return d
def test_header(self):
"""
AuthenticationClient.get_authorization_header() returns a value to be
- used for the Authorization header.
+ used for the Authorization header, which is ASCII-encoded if
+ necessary.
"""
from oauth2client.client import SignedJwtAssertionCredentials
class NoNetworkCreds(SignedJwtAssertionCredentials):
def refresh(self, http):
- self.access_token = "xxx"
+ self.access_token = u"xxx"
auth = googlestorage_container.AuthenticationClient(
"u@example.com", "xxx123",
_credentialsClass=NoNetworkCreds,
result = []
auth.get_authorization_header().addCallback(result.append)
self.assertEqual(result, ["Bearer xxx"])
+ self.assertIsInstance(result[0], bytes)
def test_one_refresh(self):
"""