Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2556b7d

Browse files
Aza Tulepbergenovparthea
Aza Tulepbergenov
authored andcommitted
feat: adds support for audience in client_options (#379)
feat: adds support for audience in client_options.
1 parent1e2f148 commit2556b7d

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

‎google/api_core/client_options.py‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ class ClientOptions(object):
6767
quota belongs to.
6868
credentials_file (Optional[str]): A path to a file storing credentials.
6969
scopes (Optional[Sequence[str]]): OAuth access token override scopes.
70+
api_key (Optional[str]): Google API key. ``credentials_file`` and
71+
``api_key`` are mutually exclusive.
72+
api_audience (Optional[str]): The intended audience for the API calls
73+
to the service that will be set when using certain 3rd party
74+
authentication flows. Audience is typically a resource identifier.
75+
If not set, the service endpoint value will be used as a default.
76+
An example of a valid ``api_audience`` is: "https://language.googleapis.com".
7077
7178
Raises:
7279
ValueError: If both ``client_cert_source`` and ``client_encrypted_cert_source``
@@ -81,6 +88,8 @@ def __init__(
8188
quota_project_id=None,
8289
credentials_file=None,
8390
scopes=None,
91+
api_key=None,
92+
api_audience=None,
8493
):
8594
ifclient_cert_sourceandclient_encrypted_cert_source:
8695
raiseValueError(
@@ -92,6 +101,8 @@ def __init__(
92101
self.quota_project_id=quota_project_id
93102
self.credentials_file=credentials_file
94103
self.scopes=scopes
104+
self.api_key=api_key
105+
self.api_audience=api_audience
95106

96107
def__repr__(self):
97108
return"ClientOptions: "+repr(self.__dict__)

‎tests/unit/test_client_options.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def test_constructor():
3636
"https://www.googleapis.com/auth/cloud-platform",
3737
"https://www.googleapis.com/auth/cloud-platform.read-only",
3838
],
39+
api_audience="foo2.googleapis.com",
3940
)
4041

4142
assertoptions.api_endpoint=="foo.googleapis.com"
@@ -46,6 +47,7 @@ def test_constructor():
4647
"https://www.googleapis.com/auth/cloud-platform",
4748
"https://www.googleapis.com/auth/cloud-platform.read-only",
4849
]
50+
assertoptions.api_audience=="foo2.googleapis.com"
4951

5052

5153
deftest_constructor_with_encrypted_cert_source():
@@ -83,6 +85,7 @@ def test_from_dict():
8385
"https://www.googleapis.com/auth/cloud-platform",
8486
"https://www.googleapis.com/auth/cloud-platform.read-only",
8587
],
88+
"api_audience":"foo2.googleapis.com",
8689
}
8790
)
8891

@@ -94,6 +97,8 @@ def test_from_dict():
9497
"https://www.googleapis.com/auth/cloud-platform",
9598
"https://www.googleapis.com/auth/cloud-platform.read-only",
9699
]
100+
assertoptions.api_keyisNone
101+
assertoptions.api_audience=="foo2.googleapis.com"
97102

98103

99104
deftest_from_dict_bad_argument():

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp