# google admanager 配置
- 登录 [Ad Manger](https://admanager.google.com/) 管理后台
1. 定位到 Admin -> Global settings -> network settings, 复制network name, network code, 并启用 API access
2. 定位到 Admin -> Global settings -> Ad Exchange account settings, 复制Publisher ID,只需要纯数字,前导“pub-”不需要
- 登录 [google云控制台](https://console.cloud.google.com/projectcreate) 创建项目(项目名统一使用report-{publisher_id后4位数字},如report-1699),组织可不选
- 配置权限请求页面,https://console.cloud.google.com/apis/credentials
外部应用,配置appname(同project名),email(gmail邮箱),授权网域(shengboglobal.com),contact email(gmail邮箱),test users(gmail邮箱) 就可以
- 创建oauth客户端,web引用,名称(名称$project_name+client,如report-demo-436210-client)js来源,https://backstage.shengboglobal.com
授权重定向URI,每个项目的授权链接不一样,https://backstage.shengboglobal.com/ApiAdsense/auth/project/<publisher_id后4位数字>.html
- 在oauth权限请求页面添加测试用户,在https://www.google.com/adsense添加访问用户,用adsense账号的宿主邮箱
- 启用adsense manage api,访问https://console.cloud.google.com/apis/dashboard,点击启用API和服务,搜索Google Ad Manager API选择Google Ad Manager API,启用它
- 后台配置客户端信息,https://backstage.shengboglobal.com/Adsensetoken/index.html,更新token配置
- 授权,获取token,https://backstage.shengboglobal.com/ApiAdmanager/auth/project/1699.html
- crontab 执行
- 若 token 频繁过期,需要检查发布状态是否为 **In production**;Testing 状态下,External 应用的授权会在 7 天后失效
1. 在 [Branding](https://console.cloud.google.com/auth/branding) 页面,更新官网和隐私链接
2. 官网链接: https://www.shengboglobal.com/
3. 隐私链接: https://www.shengboglobal.com/Privacy_Policy.html
4. 点击保存后,切换到 [Audience](https://console.cloud.google.com/auth/audience) 将发布状态切换为 "In production"
5. 重新授权(必须)
- [google Refresh token expiration说明](https://developers.google.com/identity/protocols/oauth2#expiration)