(encoded_jwt, url)
return key
Get public key for JWT in order to verify the signature.

    The keys get cached in order to limit the amount of network round trips.

    Args:
        encoded_jwt: Base64 encoded JWT.
        url: URL where keys can be fetched.

    Raises:
        JwTKeyError if keys cannot be fetched.

    Returns:
        Key as string.
Get public key for JWT in order to verify the signature.
Get public key for JWT in order to verify the signature .
def get_public_key_for_jwt(encoded_jwt, url):
    """Get public key for JWT in order to verify the signature.

    The keys get cached in order to limit the amount of network round trips.

    Args:
        encoded_jwt: Base64 encoded JWT.
        url: URL where keys can be fetched.

    Raises:
        JwTKeyError if keys cannot be fetched.

    Returns:
        Key as string.
    """
    # Get the Key ID from the JWT header.
    key_id = jwt.get_unverified_header(encoded_jwt).get('kid')
    if not key_id:
        raise JwtKeyError('Missing key ID field in token header')
    key_cache = get_public_key_for_jwt.key_cache
    key = key_cache.get(key_id)
    if key:
        return key

    # Re-fetch the key file.
    keys_json = _fetch_public_keys(url)
    if 'keys' in keys_json:
        _new_keys_dict = {}
        for key_dict in keys_json['keys']:
            public_key = jwt.algorithms.RSAAlgorithm.from_jwk(
                json.dumps(key_dict))
            _new_keys_dict[key_dict['kid']] = public_key
        key_cache = _new_keys_dict
    else:
        key_cache = keys_json
    get_public_key_for_jwt.key_cache = key_cache
    key = key_cache.get(key_id)
    if not key:
        raise JwtKeyError('IAP public key {!r} not found'.format(key_id))

    return key
def get_public_key_for_jwt ( encoded_jwt , url ) : # Get the Key ID from the JWT header. key_id = jwt . get_unverified_header ( encoded_jwt ) . get ( 'kid' ) if not key_id : raise JwtKeyError ( 'Missing key ID field in token header' ) key_cache = get_public_key_for_jwt . key_cache key = key_cache . get ( key_id ) if key : return key # Re-fetch the key file. keys_json = _fetch_public_keys ( url ) if 'keys' in keys_json : _new_keys_dict = { } for key_dict in keys_json [ 'keys' ] : public_key = jwt . algorithms . RSAAlgorithm . from_jwk ( json . dumps ( key_dict ) ) _new_keys_dict [ key_dict [ 'kid' ] ] = public_key key_cache = _new_keys_dict else : key_cache = keys_json get_public_key_for_jwt . key_cache = key_cache key = key_cache . get ( key_id ) if not key : raise JwtKeyError ( 'IAP public key {!r} not found' . format ( key_id ) ) return key