我想将在我的网站中注册的电子邮件地址保存在预定义的单个Google帐户的联系人中。 Google people API仅通过OAuth起作用。这里存储的目的地是固定的,因此我猜想不需要身份验证。怎么做?以下curl请求对我不起作用。甚至Google's try API page都显示API密钥身份验证,但会引发错误。
curl --request POST \
'https://people.googleapis.com/v1/people:createContact?key=[YOUR_API_KEY]' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{"emailAddresses":[{"value":"john.doe@gmail.com","displayName":"John Doe"}]}' \
--compressed
{
"error": {
"code": 401,
"message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
"status": "UNAUTHENTICATED"
}
}