| OLD | NEW |
| (Empty) |
| 1 from boto.auth_handler import AuthHandler | |
| 2 from boto.auth_handler import NotReadyToAuthenticate | |
| 3 import oauth2_client | |
| 4 import oauth2_helper | |
| 5 | |
| 6 class OAuth2Auth(AuthHandler): | |
| 7 | |
| 8 capability = ['google-oauth2', 's3'] | |
| 9 | |
| 10 def __init__(self, path, config, provider): | |
| 11 if (provider.name == 'google' | |
| 12 and config.has_option('Credentials', 'gs_oauth2_refresh_token')): | |
| 13 | |
| 14 self.oauth2_client = oauth2_helper.OAuth2ClientFromBotoConfig(config) | |
| 15 | |
| 16 self.refresh_token = oauth2_client.RefreshToken( | |
| 17 self.oauth2_client, | |
| 18 config.get('Credentials', 'gs_oauth2_refresh_token')) | |
| 19 else: | |
| 20 raise NotReadyToAuthenticate() | |
| 21 | |
| 22 def add_auth(self, http_request): | |
| 23 http_request.headers['Authorization'] = \ | |
| 24 self.refresh_token.GetAuthorizationHeader() | |
| OLD | NEW |