Invalid token: JWK must contain an "alg" parameter
00:27 30 Nov 2023

I am trying to validate the Azure AD JWT token in my CakePHP Application but I am failing with following part

$keys = JWK::parseKeySet($jwks);

It always tells me that I need an "alg" parameter, even if the documentation says that is optional. First I am fetching the public key from microsoft, decode it and parse it. This is the way I am trying to use it:

        $jwksUri = 'https://login.microsoftonline.com/common/discovery/keys'; 
        $jwksJson = file_get_contents($jwksUri);
        $jwks = json_decode($jwksJson, true);
        $keys = JWK::parseKeySet($jwks);
        $decodedToken = JWT::decode($accessToken,new Key($keys, 'HS256'));

Can someone help me out?

cakephp jwt