Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot locate jwt package in app_check.py after updating to firebase-admin-python V6.0.0 #653

Closed
kdfriedman opened this issue Oct 13, 2022 · 3 comments · Fixed by #654 or #655
Closed
Assignees

Comments

@kdfriedman
Copy link

[REQUIRED] Step 2: Describe your environment

  • Operating System version: MacOS 10.15.7
  • Firebase SDK version: V6.0.0
  • Firebase Product: app_check
  • Python version: 3.7.9
  • Pip version: 22.1.2

[REQUIRED] Step 3: Describe the problem

Updated to V6.0.0 and attempted to run my development server within Flask and encountered the following errors:

Error: While importing 'api', an ImportError was raised:

Traceback (most recent call last):
  File "/Users/kdfriedman/Desktop/curate-ai-python-api/env/lib/python3.7/site-packages/flask/cli.py", line 218, in locate_app
    __import__(module_name)
  File "/Users/kdfriedman/Desktop/curate-ai-python-api/api/api.py", line 2, in <module>
    from auth import validate_auth, validate_app
  File "/Users/kdfriedman/Desktop/curate-ai-python-api/api/auth.py", line 2, in <module>
    from service.firebase import verify_auth_token, verify_app_token
  File "/Users/kdfriedman/Desktop/curate-ai-python-api/api/service/firebase.py", line 2, in <module>
    from firebase_admin import credentials, auth, firestore, app_check
  File "/Users/kdfriedman/Desktop/curate-ai-python-api/env/lib/python3.7/site-packages/firebase_admin/app_check.py", line 18, in <module>
    import jwt
ModuleNotFoundError: No module named 'jwt'

After attempting to install the jwt package to fix the issue, a new error occurred:

Error: While importing 'api', an ImportError was raised:

Traceback (most recent call last):
  File "/Users/kdfriedman/Desktop/curate-ai-python-api/env/lib/python3.7/site-packages/flask/cli.py", line 218, in locate_app
    __import__(module_name)
  File "/Users/kdfriedman/Desktop/curate-ai-python-api/api/api.py", line 2, in <module>
    from auth import validate_auth, validate_app
  File "/Users/kdfriedman/Desktop/curate-ai-python-api/api/auth.py", line 2, in <module>
    from service.firebase import verify_auth_token, verify_app_token
  File "/Users/kdfriedman/Desktop/curate-ai-python-api/api/service/firebase.py", line 2, in <module>
    from firebase_admin import credentials, auth, firestore, app_check
  File "/Users/kdfriedman/Desktop/curate-ai-python-api/env/lib/python3.7/site-packages/firebase_admin/app_check.py", line 19, in <module>
    from jwt import PyJWKClient, ExpiredSignatureError, InvalidTokenError
ImportError: cannot import name 'PyJWKClient' from 'jwt' (/Users/kdfriedman/Desktop/curate-ai-python-api/env/lib/python3.7/site-packages/jwt/__init__.py)

Steps to reproduce:

I updated to V6 of the SDK and immediately encountered this issue. When I attempted to install the jwt package, a different error occurred.

Relevant Code:

import firebase_admin
from firebase_admin import credentials, auth, firestore, app_check
import os

# Initialize the default app
ENV_KEYS = {
    "CREDS_GO_HERE"
}

CREDENTIALS = credentials.Certificate(ENV_KEYS)
firebase_app = firebase_admin.initialize_app(CREDENTIALS)

verify_app_token = app_check.verify_token
@google-oss-bot
Copy link

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

@lahirumaramba
Copy link
Member

Hey @kdfriedman, Thank you for reporting this issue!
I think we need to add the new dependency to setup.py to include it in the final artifacts. I will submit a fix for this.
In the meantime, could you check installing the dependency pyjwt in your project would fix this issue?

pip install pyjwt[crypto]

Thanks!

@kdfriedman
Copy link
Author

Thanks for the update! Yea, installing that particular package fixed my issue. Thanks again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants