googleapis / googleapis/python-genai

register_files should not require google.auth.credentials.Credentials when client uses Gemini API Key

Aperta
#2,535 8 commenti 0 reazioni 1 assegnatario Rivendicata da @Venkaiahbabuneelam Vedi su GitHub
priority: p2 type: bug
Lingua principale
Python
Stelle
4k
Fork
1k
Merge medio
2g 12h
PR unite (30g)
41

Descrizione

#### Environment details

- Programming language: Python 3.14
- OS: Linux
- Package version: 1.68.0

#### Steps to reproduce

`register_files` currently requires `google.auth.credentials.Credentials`.

But the API request was rejected by Gemini API backend when:
1. a `google.auth.credentials.Credentials` is supplied; **and**
2. the client is instantiated with a Gemini API Key.

```
ClientError: 401 UNAUTHENTICATED. {'error': {'code': 401, 'message': 'API key for authentication is used with other authentication credentials. Expected only one form of authentication.', 'status': 'UNAUTHENTICATED', 'details': [{'@type':
'type.googleapis.com/google.rpc.ErrorInfo', 'reason': 'OVERLOADED_CREDENTIALS', 'metadata': {'method': 'google.ai.generativelanguage.v1beta.FileService.RegisterFiles', 'service': 'generativelanguage.googleapis.com'}}]}}
```

When calling the file register API directly with only the Gemini API Key (service account bound), it works as expected.

It requires a workaround to call the private `_register_files` method to dance around this check. This seems to be the case even for the latest google-genai@2.7.0.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.