Skip to content

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

@kdfriedman

Description

@kdfriedman

[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

Activity

google-oss-bot

google-oss-bot commented on Oct 13, 2022

@google-oss-bot

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

lahirumaramba

lahirumaramba commented on Oct 14, 2022

@lahirumaramba
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

kdfriedman commented on Oct 14, 2022

@kdfriedman
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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

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