فهرست منبع

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):