@@ -43,6 +43,7 @@ class {{ service.grpc_asyncio_transport_name }}({{ service.name }}Transport):
4343 def create_channel(cls,
4444 host: str{% if service .host %} = '{{ service.host }}'{% endif %} ,
4545 credentials: credentials.Credentials = None,
46+ credentials_file: Optional[str] = None,
4647 scopes: Optional[Sequence[str]] = None,
4748 **kwargs) -> aio.Channel:
4849 """Create and return a gRPC AsyncIO channel object.
@@ -53,6 +54,9 @@ class {{ service.grpc_asyncio_transport_name }}({{ service.name }}Transport):
5354 credentials identify this application to the service. If
5455 none are specified, the client will attempt to ascertain
5556 the credentials from the environment.
57+ credentials_file (Optional[str]): A file with credentials that can
58+ be loaded with :func:`google.auth.load_credentials_from_file`.
59+ This argument is ignored if ``channel`` is provided.
5660 scopes (Optional[Sequence[str]]): A optional list of scopes needed for this
5761 service. These are only used when credentials are not specified and
5862 are passed to :func:`google.auth.default`.
@@ -65,13 +69,16 @@ class {{ service.grpc_asyncio_transport_name }}({{ service.name }}Transport):
6569 return grpc_helpers_async.create_channel(
6670 host,
6771 credentials=credentials,
72+ credentials_file=credentials_file,
6873 scopes=scopes,
6974 **kwargs
7075 )
7176
7277 def __init__(self, *,
7378 host: str{% if service .host %} = '{{ service.host }}'{% endif %} ,
7479 credentials: credentials.Credentials = None,
80+ credentials_file: Optional[str] = None,
81+ scopes: Optional[Sequence[str]] = None,
7582 channel: aio.Channel = None,
7683 api_mtls_endpoint: str = None,
7784 client_cert_source: Callable[[], Tuple[bytes, bytes]] = None) -> None:
@@ -86,6 +93,12 @@ class {{ service.grpc_asyncio_transport_name }}({{ service.name }}Transport):
8693 are specified, the client will attempt to ascertain the
8794 credentials from the environment.
8895 This argument is ignored if ``channel`` is provided.
96+ credentials_file (Optional[str]): A file with credentials that can
97+ be loaded with :func:`google.auth.load_credentials_from_file`.
98+ This argument is ignored if ``channel`` is provided.
99+ scopes (Optional[Sequence[str]]): A optional list of scopes needed for this
100+ service. These are only used when credentials are not specified and
101+ are passed to :func:`google.auth.default`.
89102 channel (Optional[aio.Channel]): A ``Channel`` instance through
90103 which to make calls.
91104 api_mtls_endpoint (Optional[str]): The mutual TLS endpoint. If
@@ -98,8 +111,10 @@ class {{ service.grpc_asyncio_transport_name }}({{ service.name }}Transport):
98111 is None.
99112
100113 Raises:
101- google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
114+ google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
102115 creation failed for any reason.
116+ google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
117+ and ``credentials_file`` are passed.
103118 """
104119 if channel:
105120 # Sanity check: Ensure that channel and credentials are not both
@@ -125,12 +140,19 @@ class {{ service.grpc_asyncio_transport_name }}({{ service.name }}Transport):
125140 self._grpc_channel = type(self).create_channel(
126141 host,
127142 credentials=credentials,
143+ credentials_file=credentials_file,
128144 ssl_credentials=ssl_credentials,
129- scopes=self.AUTH_SCOPES,
145+ scopes=scopes or self.AUTH_SCOPES,
130146 )
131147
132148 # Run the base constructor.
133- super().__init__(host=host, credentials=credentials)
149+ super().__init__(
150+ host=host,
151+ credentials=credentials,
152+ credentials_file=credentials_file,
153+ scopes=scopes or self.AUTH_SCOPES
154+ )
155+
134156 self._stubs = {}
135157
136158 @property
0 commit comments