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

auth.verify_id_token throwing ValueError #766

Open
erwanmace opened this issue Feb 1, 2024 · 1 comment
Open

auth.verify_id_token throwing ValueError #766

erwanmace opened this issue Feb 1, 2024 · 1 comment

Comments

@erwanmace
Copy link

erwanmace commented Feb 1, 2024

  • 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)
@lahirumaramba
Copy link
Member

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?

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

No branches or pull requests

3 participants