Index: rietveld.py |
diff --git a/rietveld.py b/rietveld.py |
index 88a1b29aea875690e20159c0613fbfe04c1cdb82..b02fc394072d8ade484f8850851e7d873be6cefe 100644 |
--- a/rietveld.py |
+++ b/rietveld.py |
@@ -447,7 +447,7 @@ class Rietveld(object): |
class OAuthRpcServer(object): |
def __init__(self, |
host, |
- client_id, |
+ client_email, |
client_private_key, |
private_key_password='notasecret', |
user_agent=None, |
@@ -455,7 +455,7 @@ class OAuthRpcServer(object): |
extra_headers=None): |
"""Wrapper around httplib2.Http() that handles authentication. |
- client_id: client id for service account |
+ client_email: email associated with the service account |
client_private_key: encrypted private key, as a string |
private_key_password: password used to decrypt the private key |
""" |
@@ -478,12 +478,12 @@ class OAuthRpcServer(object): |
self.extra_headers = extra_headers or {} |
if not oa2client.HAS_OPENSSL: |
- logging.error("Support for OpenSSL hasn't been found, " |
+ logging.error("No support for OpenSSL has been found, " |
"OAuth2 support requires it.") |
logging.error("Installing pyopenssl will probably solve this issue.") |
raise RuntimeError('No OpenSSL support') |
creds = oa2client.SignedJwtAssertionCredentials( |
- client_id, |
+ client_email, |
client_private_key, |
'https://www.googleapis.com/auth/userinfo.email', |
private_key_password=private_key_password, |
@@ -516,7 +516,7 @@ class OAuthRpcServer(object): |
if payload is not None: |
method = 'POST' |
headers['Content-Type'] = content_type |
- raise NotImplementedError('POST requests are not yet supported.') |
+# raise NotImplementedError('POST requests are not yet supported.') |
Sergey Berezin
2014/04/14 20:59:42
Let's remove this comment.
pgervais
2014/04/14 21:28:05
Done.
|
prev_timeout = self._http.timeout |
try: |
@@ -527,11 +527,14 @@ class OAuthRpcServer(object): |
if kwargs: |
url += "?" + urllib.urlencode(kwargs) |
+ logging.info(url) |
Sergey Berezin
2014/04/14 20:59:42
Please add a meaningful message to the log.
pgervais
2014/04/14 21:28:05
Removed it (was for testing, and forgotten)
|
ret = self._http.request(url, |
method=method, |
body=payload, |
headers=headers) |
- if not ret[0]['content-location'].startswith(self.host): |
+ |
+ if (method == 'GET' |
+ and not ret[0]['content-location'].startswith(self.host)): |
upload.logging.warning('Redirection to host %s detected: ' |
'login may have failed/expired.' |
% urlparse.urlparse( |
@@ -552,18 +555,28 @@ class JwtOAuth2Rietveld(Rietveld): |
# pylint: disable=W0231 |
def __init__(self, |
url, |
- client_id, |
+ client_email, |
client_private_key_file, |
private_key_password=None, |
extra_headers=None): |
+ |
+ # These attributes are accessed by commit queue. Keep them. |
+ self.email = client_email |
+ self.private_key_file = client_private_key_file |
+ |
if private_key_password is None: # '' means 'empty password' |
private_key_password = 'notasecret' |
self.url = url.rstrip('/') |
+ bot_url = self.url |
+ if not bot_url.endswith('/bots'): |
+ bot_url += '/bots' |
+ |
with open(client_private_key_file, 'rb') as f: |
client_private_key = f.read() |
- self.rpc_server = OAuthRpcServer(url, |
- client_id, |
+ logging.info('Using login: %s' % client_email) |
Sergey Berezin
2014/04/14 20:59:42
Would it make sense to say 'Using OAuth login: %s'
Sergey Berezin
2014/04/14 22:49:46
What about this comment?
pgervais
2014/04/14 23:10:43
Sorry, I've overlooked it completely. I definitely
|
+ self.rpc_server = OAuthRpcServer(bot_url, |
+ client_email, |
client_private_key, |
private_key_password=private_key_password, |
extra_headers=extra_headers or {}) |