Reputation: 245
Yesterday, I have been reading and writing to the firestore database without any problem. But today it keeps on giving me such type of errors.
Traceback (most recent call last): File "C:\Users\User1\AppData\Local\Programs\Python\Python310\lib\site-packages\google\api_core\grpc_helpers.py", line 57, in error_remapped_callable return callable_(*args, **kwargs) File "C:\Users\User1\AppData\Local\Programs\Python\Python310\lib\site-packages\grpc_channel.py", line 946, in call return _end_unary_response_blocking(state, call, False, None) File "C:\Users\User1\AppData\Local\Programs\Python\Python310\lib\site-packages\grpc_channel.py", line 849, in _end_unary_response_blocking raise _InactiveRpcError(state) grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with: status = StatusCode.UNAVAILABLE details = "Getting metadata from plugin failed with error: ('invalid_grant: Invalid JWT: Token must be a short-lived token (60 minutes) and in a reasonable timeframe. Check your iat and exp values in the JWT claim.', {'error': 'invalid_grant', 'error_description': 'Invalid JWT: Token must be a short-lived token (60 minutes) and in a reasonable timeframe. Check your iat and exp values in the JWT claim.'})" debug_error_string = "{"created":"@1650858719.392000000","description":"Getting metadata from plugin failed with error: ('invalid_grant: Invalid JWT: Token must be a short-lived token (60 minutes) and in a reasonable timeframe. Check your iat and exp values in the JWT claim.', {'error': 'invalid_grant', 'error_description': 'Invalid JWT: Token must be a short-lived token (60 minutes) and in a reasonable timeframe. Check your iat and exp values in the JWT claim.'})","file":"src/core/lib/security/credentials/plugin/plugin_credentials.cc","file_line":92,"grpc_status":14}"
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "C:\Users\User1\AppData\Local\Programs\Python\Python310\lib\site-packages\google\api_core\retry.py", line 190, in retry_target return target() File "C:\Users\User1\AppData\Local\Programs\Python\Python310\lib\site-packages\google\api_core\grpc_helpers.py", line 59, in error_remapped_callable raise exceptions.from_grpc_error(exc) from exc google.api_core.exceptions.ServiceUnavailable: 503 Getting metadata from plugin failed with error: ('invalid_grant: Invalid JWT: Token must be a short-lived token (60 minutes) and in a reasonable timeframe. Check your iat and exp values in the JWT claim.', {'error': 'invalid_grant', 'error_description': 'Invalid JWT: Token must be a short-lived token (60 minutes) and in a reasonable timeframe. Check your iat and exp values in the JWT claim.'})
The following read code is run for testing purpose
import firebase_admin
from firebase_admin import credentials
from firebase_admin import firestore
# Setup
cred = credentials.Certificate("serviceAccountKey.json")
firebase_admin.initialize_app(cred)
db=firestore.client()
# Read data
# Get a document with known id
result = db.collection('location').document("user1").get()
if result.exists:
print(result.to_dict())
Please note that I do have enough quota to get started.
Upvotes: 2
Views: 811
Reputation: 1142
As mentioned by ‘Grekkq’ , There was some problem with the certificate, usually it is because of time issues, for that make sure there is correct time on your machine. For more details you can refer to the Public Documentation where the entire setup for the cloud firestore has been well explained.
Go to IAM & admin > Service accounts in the Cloud Platform Console. Generate a new private key and save the JSON file. Then use the file to initialize the SDK:
import firebase_admin from firebase_admin import credentials from firebase_admin import firestore # Use a service account cred = credentials.Certificate('path/to/serviceAccount.json') firebase_admin.initialize_app(cred) db = firestore.client()
Upvotes: 2