我需要从 google oauth2 服务获取多个特定服务的 id 令牌。
Header
{"typ":"JWT","alg":"RS256"}.
Payload:
{
"aud": "https://www.googleapis.com/oauth2/v4/token",
"exp": "1566830430",
"iat": "1566827130",
"iss": "my_project.iam.gserviceaccount.com",
"target_audience": "www.myservice.com/location"
}
它返回给我一个 ID 令牌,以便将任何数据发布到位置服务,但我也想将数据发布到我的时间服务 (www.myservice.com/time)。
如何将这2个URL设置为目标受众?
该字段目前不支持设置多个值。
考虑将自签名 JWT [1] 发送到 https://iamcredentials.googleapis.com/v1/{name=projects//serviceAccounts/}:generateIdToken [2]。尽管它也不支持一次调用中的多个受众,但它仍然是用于获取服务帐户 ID 令牌的正确 API。
[1] https://developers.google.com/identity/protocols/OAuth2ServiceAccount#jwt-auth
[2] https://cloud.google.com/iam/credentials/reference/rest/v1/projects.serviceAccounts/generateIdToken