firebase / firebase/firebase-admin-python

[FR] Use firebase emulator for TenantManagementService

オープン
#910 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
type: feature request
主要言語
Python
スター
1.2k
フォーク
359
平均マージ
5日 6分
マージ済み PR(30日)
2

説明

**Is your feature request related to a problem? Please describe.**
Currently only the Auth client supports running against the firebase emulator when setting the `FIREBASE_AUTH_EMULATOR_HOST` environment variable. However when wanting to list for example tenants with TenantManagementService you cannot do that and it forcibly uses `TENANT_MGT_URL = 'https://identitytoolkit.googleapis.com/v2'`. The emulator itself however emulates some of these endpoints (like `/projects/{project_id}/tenants`) so some of those are supported.

**Describe the solution you'd like**
Add support for setting `FIREBASE_TENANT_EMULATOR_HOST` and use that in `_TenantManagementService`

**Describe alternatives you've considered**
Doing direct HTTP REST API calls to the emulator or extending the management service manually like

```py
class EmulatedTenantManagementService(tenant_mgt._TenantManagementService):
TENANT_MGT_URL = (
f"http://{firebase_auth_emulator_host}/identitytoolkit.googleapis.com/v2"
)

def __init__(self, app: firebase_admin.App):
super().__init__(app)
credential = _utils.EmulatorAdminCredentials()
version_header = f"Python/Admin/{firebase_admin.__version__}"
base_url = f"{self.TENANT_MGT_URL}/projects/{app.project_id}"
self.client = _http_client.JsonHttpClient(
credential=credential,
base_url=base_url,
headers={"X-Client-Version": version_header},
)

app = firebase_admin.get_app()
service = EmulatedTenantManagementService(app)
app._services[tenant_mgt._TENANT_MGT_ATTRIBUTE] = service
```

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。