我构造了一个传递CredentialsFile和用于授权的Scope的服务,然后使用正确的名称(locations/{location_id})调用GetDailyMetricsTimeSeries,但返回错误404。
ctx := context.Background()
performanceService, err := businessprofileperformance.NewService(ctx,
option.WithCredentialsFile("client_secret.json"),
option.WithScopes(Scope))
if err != nil {
log.Println(err.Error())
return
}
cm := performanceService.Locations.GetDailyMetricsTimeSeries("locations/12345...")
cm.DailyMetric("WEBSITE_CLICKS")
cm.DailyRangeStartDateYear(2022)
cm.DailyRangeStartDateMonth(6)
cm.DailyRangeStartDateDay(1)
cm.DailyRangeEndDateYear(2022)
cm.DailyRangeEndDateMonth(12)
cm.DailyRangeEndDateDay(30)
response, err := cm.Do()
if err != nil {
log.Println(err.Error())
return
}
if c := response.HTTPStatusCode; c >= 200 || c <= 299 {
j, _ := response.MarshalJSON()
log.Println(j)
}
我的client_secret. json文件如下所示
{
"type": "",
"project_id": "",
"private_key_id": "",
"private_key": "",
"client_email": "",
"client_id": "",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://accounts.google.com/o/oauth2/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": ""
}
我认为问题是location_id引用缺少主题参数,但我没有找到可以传递它的位置,我隐藏了json文件的个人信息
2条答案
按热度按时间wn9m85ua1#
您能否通过获取位置调用来验证GBP位置是否仍然存在,以及您是否可以访问它?
获取https://mybusinessbusinessinformation.googleapis.com/v1/{parent=accounts/*}/locations
404可以指示GBP位置被移除。
iqjalb3h2#
问题出在认证上,主题丢失了,所以我这样处理:
}
那么