Title: Illegal Firebase credential provided. App must be initialized with a valid credential instance error - when using another type of `google.auth.Credential` object with the SDK. · Issue #698 · firebase/firebase-admin-python · GitHub
Open Graph Title: Illegal Firebase credential provided. App must be initialized with a valid credential instance error - when using another type of `google.auth.Credential` object with the SDK. · Issue #698 · firebase/firebase-admin-python
X Title: Illegal Firebase credential provided. App must be initialized with a valid credential instance error - when using another type of `google.auth.Credential` object with the SDK. · Issue #698 · firebase/firebase-admin-python
Description: Hi there, I am having some issues using the firebase_admin python client with a credential object from outside the SDK. In my use case, I want to initialize the firebase_admin SDK using a Service Account impersonation credential to list ...
Open Graph Description: Hi there, I am having some issues using the firebase_admin python client with a credential object from outside the SDK. In my use case, I want to initialize the firebase_admin SDK using a Service A...
X Description: Hi there, I am having some issues using the firebase_admin python client with a credential object from outside the SDK. In my use case, I want to initialize the firebase_admin SDK using a Service A...
Opengraph URL: https://github.com/firebase/firebase-admin-python/issues/698
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Illegal Firebase credential provided. App must be initialized with a valid credential instance error - when using another type of `google.auth.Credential` object with the SDK.","articleBody":"Hi there, I am having some issues using the `firebase_admin` python client with a credential object from outside the SDK.\r\n\r\nIn my use case, I want to initialize the `firebase_admin` SDK using a Service Account impersonation credential to list users within the firebase environment.\r\n\r\nTo do this I tried the following:\r\n\r\n```python\r\nimport google.oauth2.credentials\r\nimport google.auth.impersonated_credentials\r\n\r\nsource_credentials = google.oauth2.credentials.Credentials(token=id_token)\r\ncredentials = google.auth.impersonated_credentials.Credentials(\r\n source_credentials=source_credentials,\r\n target_principal=my_service_account_email,\r\n target_scopes=target_scopes,\r\n lifetime=500\r\n)\r\n\r\napp_options = {'projectId': project_id}\r\nfirebase_app = firebase_admin.initialize_app(\r\n credential=firebase_credential, options=app_options)\r\n```\r\n\r\nWhen running `initialize_app` it returns an exception - `Illegal Firebase credential provided. App must be initialized with a valid credential instance`.\r\n\r\nLooking into the `firebase-admin-python` source code I was able to find the source of the problem. In `firebase_admin/__init__.py` line 209 the code checks whether the supplied `credentials` object is an instance of `firebase_admin.credentials.Base`. If not, then the SDK returns the exception.\r\n\r\nI don't understand why this is the case. Why does `firebase-admin-python` have its own credentials class which seems to just wrap `google.oauth2.credentials` objects? Why wouldn't the Firebase SDK accept a `google.oauth2.credentials` object directly?\r\n\r\nI was able to work around it by hacking the `ApplicationDefault` class that comes with the `firebase-admin-python` SDK, however this seems a bit backwards.\r\n\r\n```python\r\nfirebase_credential = firebase_admin.credentials.ApplicationDefault()\r\nfirebase_credential._g_credential = credentials\r\nfirebase_credential._project_id = SOURCE_PROJECT\r\n```\r\n\r\nIn my opinion it would be better if the firebase SDK just made use of the `google.auth` module which has a much better implementation.\r\n","author":{"url":"https://github.com/LPLabrys99","@type":"Person","name":"LPLabrys99"},"datePublished":"2023-05-04T15:35:32.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/698/firebase-admin-python/issues/698"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:590c289d-2bef-bc9e-6049-752041c6bd97 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DE28:8F603:94DC8B:CBF276:698F3447 |
| html-safe-nonce | 939c37377a0a5f6c674a9675b630bf79ee93b65a18010fccae2803e5cfb13c63 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERTI4OjhGNjAzOjk0REM4QjpDQkYyNzY6Njk4RjM0NDciLCJ2aXNpdG9yX2lkIjoiNjcxNDY1ODg2OTExNTU2NTEyNyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 9088a404ef3dd802d12a2af02fa5b1de84b81e5336d764ec5a057028356aee88 |
| hovercard-subject-tag | issue:1696257852 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/firebase/firebase-admin-python/698/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c6b9f86d1f3654a78c6541b1b96fb13c989fdd6e46ce2c6a3ae48cfaf92997ea/firebase/firebase-admin-python/issues/698 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c6b9f86d1f3654a78c6541b1b96fb13c989fdd6e46ce2c6a3ae48cfaf92997ea/firebase/firebase-admin-python/issues/698 |
| og:image:alt | Hi there, I am having some issues using the firebase_admin python client with a credential object from outside the SDK. In my use case, I want to initialize the firebase_admin SDK using a Service A... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | LPLabrys99 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 6102991c714c1a6a27d05fb4f96ea6ca87a6750b4f093b95cc57ed1b84b145a1 |
| turbo-cache-control | no-preview |
| go-import | github.com/firebase/firebase-admin-python git https://github.com/firebase/firebase-admin-python.git |
| octolytics-dimension-user_id | 1335026 |
| octolytics-dimension-user_login | firebase |
| octolytics-dimension-repository_id | 84979152 |
| octolytics-dimension-repository_nwo | firebase/firebase-admin-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 84979152 |
| octolytics-dimension-repository_network_root_nwo | firebase/firebase-admin-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | e2fe82f90e107669021e243add8f74ea2a9be1b3 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width