[ 
https://issues.apache.org/jira/browse/LIBCLOUD-627?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14184291#comment-14184291
 ] 

Siim Põder commented on LIBCLOUD-627:
-------------------------------------

I had fixed this locally and noticed the patch. IIRC this diff fixed the 
problem but I did not test this right now (just picked up from a local branch) 
so I'm not 100% sure of it:

{code}
diff --git a/libcloud/common/google.py b/libcloud/common/google.py
index 52692e6..ec9f52f 100644
--- a/libcloud/common/google.py
+++ b/libcloud/common/google.py
@@ -78,7 +78,7 @@ import os
 import socket
 import sys
 
-from libcloud.utils.py3 import httplib, urlencode, urlparse, PY3
+from libcloud.utils.py3 import b, httplib, urlencode, urlparse, PY3
 from libcloud.common.base import (ConnectionUserAndKey, JsonResponse,
                                   PollingConnection)
 from libcloud.common.types import (ProviderError,
@@ -425,7 +425,7 @@ class 
GoogleServiceAcctAuthConnection(GoogleBaseAuthConnection):
         """
         # The header is always the same
         header = {'alg': 'RS256', 'typ': 'JWT'}
-        header_enc = base64.urlsafe_b64encode(json.dumps(header))
+        header_enc = base64.urlsafe_b64encode(b(json.dumps(header)))
 
         # Construct a claim set
         claim_set = {'iss': self.user_id,
@@ -433,10 +433,10 @@ class 
GoogleServiceAcctAuthConnection(GoogleBaseAuthConnection):
                      'aud': 'https://accounts.google.com/o/oauth2/token',
                      'exp': int(time.time()) + 3600,
                      'iat': int(time.time())}
-        claim_set_enc = base64.urlsafe_b64encode(json.dumps(claim_set))
+        claim_set_enc = base64.urlsafe_b64encode(b(json.dumps(claim_set)))
 
         # The message contains both the header and claim set
-        message = '%s.%s' % (header_enc, claim_set_enc)
+        message = b('%s.%s' % (header_enc, claim_set_enc))
         # Then the message is signed using the key supplied
         key = RSA.importKey(self.key)
         hash_func = SHA256.new(message)
@@ -444,7 +444,7 @@ class 
GoogleServiceAcctAuthConnection(GoogleBaseAuthConnection):
         signature = base64.urlsafe_b64encode(signer.sign(hash_func))
 
         # Finally the message and signature are sent to get a token
-        jwt = '%s.%s' % (message, signature)
+        jwt = b('%s.%s' % (message, signature))
         request = {'grant_type': 'urn:ietf:params:oauth:grant-type:jwt-bearer',
                    'assertion': jwt}
 
{code}

> service account auth fails with gce driver on python3
> -----------------------------------------------------
>
>                 Key: LIBCLOUD-627
>                 URL: https://issues.apache.org/jira/browse/LIBCLOUD-627
>             Project: Libcloud
>          Issue Type: Bug
>          Components: Compute
>            Reporter: Siim Põder
>            Priority: Minor
>
> Fails due to string/binary confusion in GoogleServiceAcctAuthConnection.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to