Getting the clientId in a custom REST endpoint


I’m writing a custom REST endpoint. I’d like to get the clientId used by the authenticated user that is calling the endpoint. I tried


but both of those are null.

I see that the clientId is in the “Authorized party” (azp) field in the JWT access token, but is that the correct/reliable way to get it?

Thanks for any advice!