firebase-admin-python icon indicating copy to clipboard operation
firebase-admin-python copied to clipboard

auth.verify_id_token throwing ValueError

Open erwanmace opened this issue 1 year ago • 1 comments

  • Operating System version: App Engine / Flask
  • Firebase SDK version: iOS Firebase SDK 10.20 / Python firebase-admin 6.4
  • Firebase Product: Auth
  • Python version: 3.11

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)

erwanmace avatar Feb 01 '24 01:02 erwanmace

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?

lahirumaramba avatar Feb 01 '24 19:02 lahirumaramba