Exemple #1
0
 def _credentials_refresh(self, credentials):
   http = HttpMockSequence([
       ({'status': '200'}, '{"access_token":"1/3w","expires_in":3600}'),
       ({'status': '401'}, ''),
       ({'status': '200'}, '{"access_token":"3/3w","expires_in":3600}'),
       ({'status': '200'}, 'echo_request_headers'),
   ])
   http = credentials.authorize(http)
   _, content = http.request('http://example.org')
   return content
Exemple #2
0
 def test_credentials_good(self):
   private_key = datafile('privatekey.%s' % self.format)
   credentials = SignedJwtAssertionCredentials(
       '*****@*****.**',
       private_key,
       scope='read+write',
       sub='*****@*****.**')
   http = HttpMockSequence([
       ({'status': '200'}, '{"access_token":"1/3w","expires_in":3600}'),
       ({'status': '200'}, 'echo_request_headers'),
   ])
   http = credentials.authorize(http)
   _, content = http.request('http://example.org')
   self.assertEqual('Bearer 1/3w', content['Authorization'])