问题描述
我要链接并查看与Google Adwords链接的分析帐户。
使用的程序:
- 使用以下网址对范围为“ Ananlytics和Adwords”的Google帐户进行身份验证 https://www.googleapis.com/auth/adwords https://www.googleapis.com/auth/analytics
- 获得身份验证响应后,创建Google Analytics(分析)服务对象。
- 已附加Google广告链接API抛出错误“权限不足”屏幕截图
脚本:
exibble %>%
mutate(fruit = c('durian','coconut','banana','apricot','honeydew','grapefruit','fig',NA)) %>%
mutate(currency = c('65100.000','1.390','17.950','49.950','0.440',NA,'13.255','1325.810')) %>%
select(group,fruit,currency) %>%
gt(groupname_col = 'group',rowname_col = 'fruit')
所需结果:与adwords帐户关联的分析帐户列表。
解决方法
您缺少Google Analytics(分析)中管理实体的作用域,请查看此https://developers.google.com/identity/protocols/oauth2/scopes#analytics
请使用“ https://www.googleapis.com/auth/analytics.edit”更新您的范围
我建议的更新:
function googleAuth(){
if (!empty($code)) {
--------------
---- Your existing script ----
--------------
} else {
if (!empty($id)) {
header("Location:https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=" . Configure::read('GOOGLE_OAUTH_CLIENT_ID') . "&redirect_uri=" . Configure::read('GOOGLE_OAUTH_REDIRECT_URI') . "&access_type=offline&approval_prompt=force&state=" . $id . "&scope=https://www.googleapis.com/auth/adwords%20https://www.googleapis.com/auth/analytics%20https://www.googleapis.com/auth/analytics.edit");
exit;
}
}
}
参考网址: https://developers.google.com/identity/protocols/oauth2/scopes#analytics