Преглед изворни кода

Add back support for application default creds

However, one test that generates signed urls for objects will fail is this is
used instead of service accounts.
Ehsan Chiniforooshan пре 7 година
родитељ
комит
f5f6148c72
1 измењених фајлова са 8 додато и 3 уклоњено
  1. 8 3
      cloudbridge/cloud/providers/gce/provider.py

+ 8 - 3
cloudbridge/cloud/providers/gce/provider.py

@@ -16,6 +16,7 @@ from cloudbridge.cloud.interfaces.exceptions import ProviderConnectionException
 import googleapiclient
 from googleapiclient import discovery
 
+from oauth2client.client import GoogleCredentials
 from oauth2client.service_account import ServiceAccountCredentials
 
 from .services import GCEComputeService
@@ -286,9 +287,13 @@ class GCECloudProvider(BaseCloudProvider):
     @property
     def _credentials(self):
         if not self._credentials_cache:
-            self._credentials_cache = (
-                    ServiceAccountCredentials.from_json_keyfile_dict(
-                            self.credentials_dict))
+            if self.credentials_dict:
+                self._credentials_cache = (
+                        ServiceAccountCredentials.from_json_keyfile_dict(
+                                self.credentials_dict))
+            else:
+                self._credentials_cache = (
+                        GoogleCredentials.get_application_default())
         return self._credentials_cache
 
     def sign_blob(self, string_to_sign):