Repository: googleapis/google-cloud-python

Issue:
resource manager CAN be used with service account credentials
Not implemented errors on constructing clients from service accounts are inaccurate. Cloud Resource Manager CAN be called with service accounts. Those methods should be implemented. 



Discussion:
@elibixby Thanks for the update. When the original implementation (#1083) was done, only user accounts worked. Verifying now and then will send a PR.

Confirmed. This also opens it up so that we can write system tests. Any suggestions for things that should be tested?


Resolving patch:
diff --git a/gcloud/resource_manager/client.py b/gcloud/resource_manager/client.py
--- a/gcloud/resource_manager/client.py
+++ b/gcloud/resource_manager/client.py
@@ -48,36 +48,6 @@ class Client(BaseClient):
 
     _connection_class = Connection
 
-    @classmethod
-    def from_service_account_json(cls, *args, **kwargs):
-        """Factory to retrieve JSON credentials while creating client.
-
-        The behavior from the parent class is disabled here since the Resource
-        Manager API can only use credentials from a user account, not a
-        service account.
-
-        :raises: :class:`NotImplementedError <exceptions.NotImplementedError>`
-                 always.
-        """
-        raise NotImplementedError('A service account cannot be used with the '
-                                  'Resource Manager API. Only user '
-                                  'credentials can be used.')
-
-    @classmethod
-    def from_service_account_p12(cls, *args, **kwargs):
-        """Factory to retrieve P12 credentials while creating client.
-
-        The behavior from the parent class is disabled here since the Resource
-        Manager API can only use credentials from a user account, not a
-        service account.
-
-        :raises: :class:`NotImplementedError <exceptions.NotImplementedError>`
-                 always.
-        """
-        raise NotImplementedError('A service account cannot be used with the '
-                                  'Resource Manager API. Only user '
-                                  'credentials can be used.')
-
     def new_project(self, project_id, name=None, labels=None):
         """Creates a :class:`.Project` bound to the current client.
 
diff --git a/gcloud/resource_manager/connection.py b/gcloud/resource_manager/connection.py
--- a/gcloud/resource_manager/connection.py
+++ b/gcloud/resource_manager/connection.py
@@ -15,8 +15,6 @@
 """Create / interact with gcloud.resource_manager connections."""
 
 
-from oauth2client.client import AssertionCredentials
-
 from gcloud import connection as base_connection
 
 
@@ -42,12 +40,3 @@ class Connection(base_connection.JSONConnection):
 
     SCOPE = ('https://www.googleapis.com/auth/cloud-platform',)
     """The scopes required for authenticating as a Resouce Manager consumer."""
-
-    def __init__(self, credentials=None, http=None):
-        if isinstance(credentials, AssertionCredentials):
-            message = ('credentials (%r) inherits from '
-                       'AppAssertionCredentials. Only user credentials can be '
-                       'used with the Resource Manager API. ' % (credentials,))
-            raise TypeError(message)
-
-        super(Connection, self).__init__(credentials=credentials, http=http)


Test patch:
diff --git a/gcloud/resource_manager/test_client.py b/gcloud/resource_manager/test_client.py
--- a/gcloud/resource_manager/test_client.py
+++ b/gcloud/resource_manager/test_client.py
@@ -88,16 +88,6 @@ def test_constructor(self):
         self.assertEqual(client.connection._credentials, credentials)
         self.assertEqual(client.connection._http, http)
 
-    def test_from_service_account_json_factory(self):
-        klass = self._getTargetClass()
-        with self.assertRaises(NotImplementedError):
-            klass.from_service_account_json()
-
-    def test_from_service_account_p12_factory(self):
-        klass = self._getTargetClass()
-        with self.assertRaises(NotImplementedError):
-            klass.from_service_account_p12()
-
     def test_new_project_factory(self):
         from gcloud.resource_manager.project import Project
 
diff --git a/gcloud/resource_manager/test_connection.py b/gcloud/resource_manager/test_connection.py
--- a/gcloud/resource_manager/test_connection.py
+++ b/gcloud/resource_manager/test_connection.py
@@ -24,13 +24,6 @@ def _getTargetClass(self):
     def _makeOne(self, *args, **kw):
         return self._getTargetClass()(*args, **kw)
 
-    def test_constructor_with_assertion(self):
-        from oauth2client.client import AssertionCredentials
-
-        credentials = AssertionCredentials(None)
-        with self.assertRaises(TypeError):
-            self._makeOne(credentials=credentials)
-
     def test_build_api_url_no_extra_query_params(self):
         conn = self._makeOne()
         URI = '/'.join([