firebase / firebase-admin-python

Firebase Admin Python SDK
https://firebase.google.com/docs/admin/setup
Apache License 2.0
988 stars 300 forks source link

auth.verify_id_token throwing ValueError #766

Open erwanmace opened 4 months ago

erwanmace commented 4 months ago

Steps to reproduce:

Sending a request with Token from an iOS app using Firebase SDK 10.20

Trying to decode the token server side using auth.verify_id_token(id_token, clock_skew_seconds=60)

I have verified that id_token is a valid token and definitely not an empty string. However the above throws ValueError

Relevant Code:

    authorization = request.headers.get('Authorization')
    if authorization and authorization.startswith('Bearer '):
        id_token = authorization.split('Bearer ')[1]
        print('id_token: %s' % id_token)
    else:
        json_abort(401, message="Invalid authorization A")

    try:
        decoded_token = auth.verify_id_token(id_token, clock_skew_seconds=60)
        print('decoded_token: %s' % decoded_token)

    except auth.ExpiredIdTokenError:
        print('expired token: %s' % id_token)
        json_abort(401, message="Expired Token")

    except auth.InvalidIdTokenError:
        print('invalid token: %s' % id_token)
        json_abort(401, message="Invalid Token")

    except auth.RevokedIdTokenError:
        print('revoked token: %s' % id_token)
        json_abort(401, message="Revoked Token")

    except auth.CertificateFetchError:
        print('Certificate error: %s' % id_token)
        json_abort(401, message="Certificate error")

    except auth.UserDisabledError:
        print('UserDisabledError error: %s' % id_token)
        json_abort(401, message="UserDisabledError")

    except ValueError:
        print('Value Error: %s' % id_token)
        json_abort(401, message="Token Value Error: %s" % id_token)
lahirumaramba commented 4 months ago

Hey @erwanmace, our tests for this API seem to be passing with no issues. Are you able to share the full error message/logs with us? Are you only seeing this issue with the most recent SDK release?