Преглед на файлове

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 преди 8 години
родител
ревизия
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):