Comments (8)
Related: firebase/codelab-friendlychat-web#252
from firebase-admin-python.
It should be noted that project 764086051850 != my dev project. I've seen similar problems when the library requires a service account credentials file instead of accepting application default credentials (which is stupid :) IMO).
from firebase-admin-python.
When running locally you must set up application default credentials (ADC) by setting the GOOGLE_APPLICATION_CREDENTIALS
environment variable. That's the only way to make this scenario work.
Identity toolkit backend API identifies the project based on the credential and credential only. When you use ADC locally without setting the environment variable, it will default to whatever project configured with the gcloud SDK.
from firebase-admin-python.
It might also work if you just set the correct project in your gcloud config:
gcloud config set project <MY_PROJECT_ID>
Haven't tested this personally though.
from firebase-admin-python.
"Identity toolkit backend API identifies the project based on the credential and credential only."
I thought that would be the response. Do we have anything in the works to change that? Or is there a reason why we aren't?
from firebase-admin-python.
The credential is sufficient to identify the project. You can (and should) continue to use Application Default Credentials (ADC) for this scenario, but when testing locally you must set up ADC via the environment variable. When deployed to the cloud (App Engine, Compute Engine), no service account file is needed and your code will just work without any changes.
There is probably a bug here where the backend API ignores the project ID set locally via the gcloud
SDK (I tested this since my last comment, and no joy). It always defaults to 764086051850, whatever that is. I've created an internal bug for the Auth team to track that.
>>> import firebase_admin
>>> from firebase_admin import auth
>>> app = firebase_admin.initialize_app()
>>> app.credential.project_id
'xxxxxxxx-xx' # Prints the project ID set via gcloud SDK
>>> auth.get_user('foo')
Traceback (most recent call last):
File "/Users/hkj/Projects/ml/env/lib/python3.6/site-packages/firebase_admin/_user_mgt.py", line 241, in get_user
response = self._request('post', 'getAccountInfo', json=payload)
File "/Users/hkj/Projects/ml/env/lib/python3.6/site-packages/firebase_admin/_user_mgt.py", line 372, in _request
resp.raise_for_status()
File "/Users/hkj/Projects/ml/env/lib/python3.6/site-packages/requests/models.py", line 935, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://www.googleapis.com/identitytoolkit/v3/relyingparty/getAccountInfo
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/hkj/Projects/ml/env/lib/python3.6/site-packages/firebase_admin/auth.py", line 117, in get_user
response = user_manager.get_user(uid=uid)
File "/Users/hkj/Projects/ml/env/lib/python3.6/site-packages/firebase_admin/_user_mgt.py", line 244, in get_user
self._handle_http_error(INTERNAL_ERROR, msg, error)
File "/Users/hkj/Projects/ml/env/lib/python3.6/site-packages/firebase_admin/_user_mgt.py", line 336, in _handle_http_error
raise ApiCallError(code, msg, error)
firebase_admin._user_mgt.ApiCallError: Failed to get user by user ID: foo.
Server response: {
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "accessNotConfigured",
"message": "Access Not Configured. Google Identity Toolkit API has not been used in project 764086051850 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/identitytoolkit.googleapis.com/overview?project=764086051850 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.",
"extendedHelp": "https://console.developers.google.com/apis/api/identitytoolkit.googleapis.com/overview?project=764086051850"
}
],
"code": 403,
"message": "Access Not Configured. Google Identity Toolkit API has not been used in project 764086051850 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/identitytoolkit.googleapis.com/overview?project=764086051850 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry."
}
}
Notice the 764086051850 in the error, which is what you got as well. And the API has ignored the project ID set on the default credential. Hopefully, the Auth team will fix this, and then you will be able to avoid having to set the environment variable.
from firebase-admin-python.
It turns out 764086051850 is a special project associated with the gcloud SDK itself. You will find this configured in the client_id
field of ~/.config/gcloud/application_default_credentials.json
(on Mac and Linux). When no service account is configured locally, the ADC obtains a token that is actually attached to this project. I don't think there's much the backend Auth team can do here, unless they decide to support specifying project ID via some other means.
from firebase-admin-python.
"The credential is sufficient to identify the project." I did try setting the gcloud project id as you suggested, to no avail. Couldn't it also be argued that specifying the project within the code (as we have done in my example) is sufficient to solve the ambiguity?
This is probably not a discussion for you and me, so sorry about pestering. I'd be happy to contribute to any discussion with the Auth team. I'm sad you said "internal bug"; I just left Google last month :( haha. Out of the club, haha.
from firebase-admin-python.
Related Issues (20)
- urllib3 connection pool full using messaging.send_each_for_multicast() HOT 2
- Failing to verify a firebase id_token on backend from NextAuth GoogleProvider HOT 1
- No longer able to use pip install for system level package install HOT 3
- [FR] Add multiple Firestore support HOT 1
- facing issues when trying to install firebase-admin in my existing project, after installing also it's throwing error. HOT 2
- Geeting lots of issues when trying to install firebase-admin in my existing project, after installing also it's throwing error. HOT 2
- No module named 'firebase_auth' --> Newly Created Projects HOT 2
- Uploading files >100 MB to the Firebase Storage fails (Firebase Emulator Suite) HOT 2
- Missing ibi (iOS bundle ID) parameter on generated email link authentication URLs
- Localhost unavailable: WSA error HOT 1
- [FR] - When using Email/Password authentication, add a way to login with the password HOT 2
- Transaction contextmanager does not set transaction to in_progress HOT 2
- python-jwt is deprecated HOT 2
- firebase_admin installed and got PyJWKClient issue HOT 2
- [FR] Download url like with node js client HOT 1
- Github Desktop Pull/Push Issue HOT 2
- [FR] Adding global var HOT 1
- Option to pass values to the transaction function callback HOT 1
- auth.verify_id_token throwing ValueError HOT 1
- [FR] Add Support for Pyodide by providing a wheel with binaries built for Emscripten. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from firebase-admin-python.