def get_jwk(header, payload)
      kid = header['kid']

      # cache hit
      return JWKS_CACHE[kid] if JWKS_CACHE[kid]
  
      # fetch jwk
      logger.info("[Okta::Jwt] Fetching public key: kid => #{kid} ...") if logger
      jwks_response = client(payload['iss']).get do |req|
        req.url get_metadata(payload)['jwks_uri']
      end
      jwk = JSON.parse(jwks_response.body)['keys'].find do |key|
        key.dig('kid') == kid
      end
  
      # cache and return the key
      jwk.tap{JWKS_CACHE[kid] = jwk}
    end
def get_jwk(header, payload)
      kid = header['kid']

      # cache hit
      return JWKS_CACHE[kid] if JWKS_CACHE[kid]
  
      # fetch jwk
      logger.info("[Okta::Jwt] Fetching public key: kid => #{kid} ...") if logger
      jwks_response = client(payload['iss']).get do |req|
        req.url get_metadata(payload)['jwks_uri']
      end
      jwk = JSON.parse(jwks_response.body)['keys'].find do |key|
        key.dig('kid') == kid
      end
  
      # cache and return the key
      jwk.tap{JWKS_CACHE[kid] = jwk}
    end
extract public key from metadata's jwks_uri using kid