okta / okta-jwt-verifier-python

okta-jwt-verifier-python
https://github.com/okta/okta-jwt-verifier-python
Apache License 2.0
32 stars 15 forks source link

JWVerifier works great on my machine,but fails when runs in docker-container #41

Open artsyanka opened 2 years ago

artsyanka commented 2 years ago

I am writing a flask-api where token-verification is done via okta-jwt-verifier. I have this code to verify tokens:

import asyncio
from okta_jwt_verifier import AccessTokenVerifier, JWTVerifier

loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)

def is_access_token_valid(token, issuer,client_id):
jwt_verifier = JWTVerifier(issuer=issuer, client_id=client_id, audience='api://default', leeway=60)
try:
    verified_token = jwt_verifier.verify_access_token(token)
    parsed=jwt_verifier.parse_token(token)
    g.decoded_token=parsed
    loop.run_until_complete(verified_token)
    return True
except Exception:
    print("Exception")
    return False  

It works great when i run this on my machine, but when I do this in docker-container (i have docker-compose.yml file with 2 services: flask and db(PostgreSQL)), the process fails at loop.run_until_complete(verified_token). I am not sure how to work around that issue. Please help if you have any ideas! Thanks in advance!

sagar-raythatha commented 1 year ago

I am also facing the same issue, were you able to resolve this?