Skip to content

Commit 9b4bf8e

Browse files
authored
Merge pull request openai#1903 from stainless-sdks/dev/jtian/remove-unnecessary-params
feat: Remove unnecessary client_id when using workload identity provider for auth
2 parents 7e527bc + c39ea8d commit 9b4bf8e

4 files changed

Lines changed: 0 additions & 17 deletions

File tree

README.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,12 @@ from openai.auth import k8s_service_account_token_provider
8383

8484
client = OpenAI(
8585
workload_identity={
86-
"client_id": "your-client-id",
8786
"identity_provider_id": "idp-123",
8887
"service_account_id": "sa-456",
8988
"provider": k8s_service_account_token_provider(
9089
"/var/run/secrets/kubernetes.io/serviceaccount/token"
9190
),
9291
},
93-
organization="org-xyz",
94-
project="proj-abc",
9592
)
9693

9794
response = client.chat.completions.create(
@@ -108,7 +105,6 @@ from openai.auth import azure_managed_identity_token_provider
108105

109106
client = OpenAI(
110107
workload_identity={
111-
"client_id": "your-client-id",
112108
"identity_provider_id": "idp-123",
113109
"service_account_id": "sa-456",
114110
"provider": azure_managed_identity_token_provider(
@@ -126,7 +122,6 @@ from openai.auth import gcp_id_token_provider
126122

127123
client = OpenAI(
128124
workload_identity={
129-
"client_id": "your-client-id",
130125
"identity_provider_id": "idp-123",
131126
"service_account_id": "sa-456",
132127
"provider": gcp_id_token_provider(audience="https://api.openai.com/v1"),
@@ -146,7 +141,6 @@ def get_custom_token() -> str:
146141

147142
client = OpenAI(
148143
workload_identity={
149-
"client_id": "your-client-id",
150144
"identity_provider_id": "idp-123",
151145
"service_account_id": "sa-456",
152146
"provider": {
@@ -165,7 +159,6 @@ from openai.auth import k8s_service_account_token_provider
165159

166160
client = OpenAI(
167161
workload_identity={
168-
"client_id": "your-client-id",
169162
"identity_provider_id": "idp-123",
170163
"service_account_id": "sa-456",
171164
"provider": k8s_service_account_token_provider("/var/token"),

src/openai/auth/_workload.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ class SubjectTokenProvider(TypedDict):
2727

2828

2929
class WorkloadIdentity(TypedDict):
30-
"""A unique string that identifies the client."""
31-
32-
client_id: str
33-
3430
"""Identity provider resource id in WIFAPI."""
3531
identity_provider_id: str
3632

@@ -253,7 +249,6 @@ def _fetch_token_from_exchange(self) -> dict[str, Any]:
253249
self.token_exchange_url,
254250
json={
255251
"grant_type": TOKEN_EXCHANGE_GRANT_TYPE,
256-
"client_id": self.workload_identity["client_id"],
257252
"subject_token": subject_token,
258253
"subject_token_type": subject_token_type,
259254
"identity_provider_id": self.workload_identity["identity_provider_id"],

tests/test_auth.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ def test_basic_auth():
3636

3737
client = OpenAI(
3838
workload_identity={
39-
"client_id": "client_123",
4039
"identity_provider_id": "idp_123",
4140
"service_account_id": "sa_123",
4241
"provider": {
@@ -82,7 +81,6 @@ def provider() -> str:
8281

8382
client = OpenAI(
8483
workload_identity={
85-
"client_id": "client_123",
8684
"identity_provider_id": "idp_123",
8785
"service_account_id": "sa_123",
8886
"provider": {
@@ -103,7 +101,6 @@ def provider() -> str:
103101
assert json.loads(exchange_request.content) == snapshot(
104102
{
105103
"grant_type": "urn:ietf:params:oauth:grant-type:token-exchange",
106-
"client_id": "client_123",
107104
"subject_token": "fake_subject_token",
108105
"subject_token_type": "urn:ietf:params:oauth:token-type:jwt",
109106
"identity_provider_id": "idp_123",
@@ -136,7 +133,6 @@ def test_workload_identity_exchange_error() -> None:
136133

137134
client = OpenAI(
138135
workload_identity={
139-
"client_id": "client_123",
140136
"identity_provider_id": "idp_123",
141137
"service_account_id": "sa_123",
142138
"provider": {

tests/test_client.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
api_key = "My API Key"
4646
admin_api_key = "My Admin API Key"
4747
workload_identity: WorkloadIdentity = {
48-
"client_id": "client_123",
4948
"identity_provider_id": "provider_123",
5049
"service_account_id": "service_account_123",
5150
"provider": {

0 commit comments

Comments
 (0)