When you use OAuthV2/GenerateJWTAccessToken, with the HS512 algorithm, You need to use SOMETHING as the secret key. HS512 is going to require a key of at least 64 bytes.
When you create an App registration in Apigee, Apigee generates a {key,secret} pair. The secret is 64 bytes in length. So you could use that secret value as the key for signing the JWT with HS512. You could use “private.mysecretkey” in the policy configuration, or some other variable name. The name of the variable doesn’t actually matter. The important thing is the value the variable holds. Whatever name you use, you need to load a value of 64 bytes into that variable.
To use the client secret as the secret key, you must first extract that secret from the base64-encoded blob that gets passed in the Authorization header. The header will look like this:
Basic NTZuQVFHT1lvU2pUWmkzb1d...lots..of...characters....m05OUxSdzl1MElLd04xV1Y2HTUhRb3RIeG0=
And you can use the BasicAuthentication policy in Apigee to extract the constituent parts from that encoded blob. That will retrieve the client_id and client_secret, and at that point you could call OAuthV2/GenerateJWTAccessToken , specifying the extracted client_secret as the variable that holds the SecretKey value. (Again, which variable name you use for SecretKey in theOAuthV2/GenerateJWTAccessToken policy, depends on how you configured the BasicAuthentication policy - in other words, which variable you told the BasicAuthentication policy to load with the decoded secret value. )
But, more importantly…
WHY are you doing this? What are you solving for here? Your title said something about “JWT Tokens for Google Healthcare API”. What does OauthV2/GenerateJWTAccessToken have to do with tokens for the Google Healthcare API?
When you use OAuthV2/GenerateJWTAccessToken with HS512, you’re generating a token that can be used by Apigee, or by any system that “knows” the secret key. I don’t think the Google Healthcare API can use that token.
If by “Healthcare API”, you are talking about the thing you can reach at healthcare.googleapis.com , then you need to pass an access token with such requests. A token you create with the Apigee policy OAuthV2/GenerateJWTAccessToken is not the right kind of token. I think in general the healthcare API expects access tokens that look like any other access token for Google cloud, which means it is an access token that has been be generated by the Google OAuth2 endpoints.
I summarized some things regarding access tokens for google properties (like healthcare.googleapis.com) here: https://github.com/DinoChiesa/get-gcp-access-token How to get them, how they work, etc.
You started by asking about a specific policy configuration in Apigee. If you take a step back and explain the entire system, and your broader goals, someone here might be able to provide more helpful advice. Including advice on whether you even need that policy.