diff --git a/firebase_admin/db.py b/firebase_admin/db.py index d42370317..1a91635d5 100644 --- a/firebase_admin/db.py +++ b/firebase_admin/db.py @@ -27,7 +27,7 @@ import threading from urllib import parse -import google.auth +from google.auth import credentials import requests import firebase_admin @@ -802,7 +802,7 @@ def get_client(self, db_url=None): credential = self._credential.get_credential() else: # Emulator base_url. Use fake credentials and specify ?ns=foo in query params. - credential = _EmulatorAdminCredentials() + credential = credentials.AnonymousCredentials() params = {'ns': namespace} if self._auth_override: params['auth_variable_override'] = self._auth_override @@ -978,12 +978,3 @@ def _extract_error_message(cls, response): message = 'Unexpected response from database: {0}'.format(response.content.decode()) return message - - -class _EmulatorAdminCredentials(google.auth.credentials.Credentials): - def __init__(self): - google.auth.credentials.Credentials.__init__(self) - self.token = 'owner' - - def refresh(self, request): - pass diff --git a/tests/test_token_gen.py b/tests/test_token_gen.py index f88c87ff4..8ee4b4b71 100644 --- a/tests/test_token_gen.py +++ b/tests/test_token_gen.py @@ -221,7 +221,7 @@ def test_sign_with_iam(self): testutils.MockCredential(), name='iam-signer-app', options=options) try: signature = base64.b64encode(b'test').decode() - iam_resp = '{{"signature": "{0}"}}'.format(signature) + iam_resp = '{{"signedBlob": "{0}"}}'.format(signature) _overwrite_iam_request(app, testutils.MockRequest(200, iam_resp)) custom_token = auth.create_custom_token(MOCK_UID, app=app).decode() assert custom_token.endswith('.' + signature.rstrip('=')) @@ -259,7 +259,7 @@ def test_sign_with_discovered_service_account(self): # Now invoke the IAM signer. signature = base64.b64encode(b'test').decode() request.response = testutils.MockResponse( - 200, '{{"signature": "{0}"}}'.format(signature)) + 200, '{{"signedBlob": "{0}"}}'.format(signature)) custom_token = auth.create_custom_token(MOCK_UID, app=app).decode() assert custom_token.endswith('.' + signature.rstrip('=')) self._verify_signer(custom_token, 'discovered-service-account')