(encoded_jwt, public_key, algorithm, expected_audience)
return None
Decode a JSON Web Token (JWT).

    Args:
        encoded_jwt: The contents of the X-Goog-IAP-JWT-Assertion header.
        public_key: Key to verify signature of the JWT.
        algorithm: Algorithm used for the key. E.g. ES256, RS256. If the
            GOOGLE_OIDC_ALGORITHM is set in the config, it will overwrite
            the algorithm used here.
        expected_audience: Expected audience in the JWT.

    Returns:
        Decoded JWT as a dict object.

    Raises:
        JwtValidationError: if the JWT token cannot be decoded.
Decode a JSON Web Token (JWT).
Decode a JSON Web Token ( JWT ) .
def decode_jwt(encoded_jwt, public_key, algorithm, expected_audience):
    """Decode a JSON Web Token (JWT).

    Args:
        encoded_jwt: The contents of the X-Goog-IAP-JWT-Assertion header.
        public_key: Key to verify signature of the JWT.
        algorithm: Algorithm used for the key. E.g. ES256, RS256. If the
            GOOGLE_OIDC_ALGORITHM is set in the config, it will overwrite
            the algorithm used here.
        expected_audience: Expected audience in the JWT.

    Returns:
        Decoded JWT as a dict object.

    Raises:
        JwtValidationError: if the JWT token cannot be decoded.
    """
    chosen_algorithm = current_app.config.get(
        'GOOGLE_OIDC_ALGORITHM', algorithm)
    try:
        decoded_jwt = jwt.decode(
            jwt=encoded_jwt, key=public_key,
            algorithms=[chosen_algorithm],
            audience=expected_audience)
        return decoded_jwt
    except (jwt.exceptions.InvalidTokenError,
            jwt.exceptions.InvalidKeyError) as e:
        raise JwtValidationError('JWT validation error: {}'.format(e)) from e

    return None
def decode_jwt ( encoded_jwt , public_key , algorithm , expected_audience ) : chosen_algorithm = current_app . config . get ( 'GOOGLE_OIDC_ALGORITHM' , algorithm ) try : decoded_jwt = jwt . decode ( jwt = encoded_jwt , key = public_key , algorithms = [ chosen_algorithm ] , audience = expected_audience ) return decoded_jwt except ( jwt . exceptions . InvalidTokenError , jwt . exceptions . InvalidKeyError ) as e : raise JwtValidationError ( 'JWT validation error: {}' . format ( e ) ) from e return None