Google api 邮递员和谷歌服务账户,如何授权?
我读过这些文件 (我已经获得服务帐户的.json凭据) 而且不能聪明 使用凭据获取身份验证令牌或api密钥的请求的地址 只有图书馆。 因此,凭据以某种方式授权,但如何使用HTTPS?找到 在JWT.io上用RS256和params签名 标题:Google api 邮递员和谷歌服务账户,如何授权?,google-api,google-cloud-storage,storage,service-accounts,Google Api,Google Cloud Storage,Storage,Service Accounts,我读过这些文件 (我已经获得服务帐户的.json凭据) 而且不能聪明 使用凭据获取身份验证令牌或api密钥的请求的地址 只有图书馆。 因此,凭据以某种方式授权,但如何使用HTTPS?找到 在JWT.io上用RS256和params签名 标题: { "alg": "RS256", "typ": "JWT", "kid": "your_private_key_id" } 有效载荷: { "iss": "your_client_email_of_service_account
{
"alg": "RS256",
"typ": "JWT",
"kid": "your_private_key_id"
}
有效载荷:
{
"iss": "your_client_email_of_service_account",
"sub": "your_client_email_of_service_account",
"aud": "https://www.googleapis.com/oauth2/v4/token",
"scope": "https://www.googleapis.com/auth/devstorage.read_only",
"iat": current_unix_time,
"exp": current_unix_time+3600
}
验证签名
最后一个字段中的\u私钥(不带\n)
得到了加密密钥
然后
POST /oauth2/v4/token HTTP/1.1
Host: www.googleapis.com
Content-Type: application/x-www-form-urlencoded
Cache-Control: no-cache
grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Ajwt-bearer&assertion=ENCODED_KEY_FROM_JWT.IO
我得到了回应
{
"access_token": "ya21.c.ElrSBodwuWANeh7Q0-zlXpOxqm9-uEszPElsY2tvoG5aPxRgOkasN5G2sMgj3iosPVbRYk1wXw_DcBnm2FtuNBlZpv_wCC0YS5pWMykR8Ouf5CZg-8OK842rvfk",
"expires_in": 3600,
"token_type": "Bearer"
}
另外,不要忘记为您的服务帐户提供一个在存储器中读取的权限
在JWT.io上用RS256和params签名
标题:
{
"alg": "RS256",
"typ": "JWT",
"kid": "your_private_key_id"
}
有效载荷:
{
"iss": "your_client_email_of_service_account",
"sub": "your_client_email_of_service_account",
"aud": "https://www.googleapis.com/oauth2/v4/token",
"scope": "https://www.googleapis.com/auth/devstorage.read_only",
"iat": current_unix_time,
"exp": current_unix_time+3600
}
验证签名
最后一个字段中的\u私钥(不带\n)
得到了加密密钥
然后
POST /oauth2/v4/token HTTP/1.1
Host: www.googleapis.com
Content-Type: application/x-www-form-urlencoded
Cache-Control: no-cache
grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Ajwt-bearer&assertion=ENCODED_KEY_FROM_JWT.IO
我得到了回应
{
"access_token": "ya21.c.ElrSBodwuWANeh7Q0-zlXpOxqm9-uEszPElsY2tvoG5aPxRgOkasN5G2sMgj3iosPVbRYk1wXw_DcBnm2FtuNBlZpv_wCC0YS5pWMykR8Ouf5CZg-8OK842rvfk",
"expires_in": 3600,
"token_type": "Bearer"
}
另外,别忘了为您的服务帐户提供读取存储的权限我想了解更多关于您如何使用Jwt.io创建令牌的信息。我想了解更多关于您如何使用Jwt.io创建令牌的信息。