Google 订阅商品/退款后台配置教程

  1.  到Google Play Console 登录开发者账号, 用 Owner 账号
  2. Setting -> Developer account -> API access 找到Service Accounts(没有Service Accounts的话,创建一个即可
  3. 点击 View In Google Developer Console跳转到Console后台
  4. 创建Credentials web application生成Client ID 和 Client Secret
  5.  参考 https://developers.google.com/android-publisher/authorization 生成refresh_token
  6. 理论上一个GooglePlay开发者账号创建一套Client ID参数即可

生成refresh_token 步骤:

1. 在浏览器中输入:https://accounts.google.com/o/oauth2/auth?scope=https://www.googleapis.com/auth/androidpublisher&response_type=code&access_type=offline&redirect_uri=${redirect_uri}&client_id=${client_id}

2. 请求地址后需要输入登陆账号,登录Owner账号(应该登陆服务账号也可以),登陆完成后将浏览器地址栏的地址复制出来,如:https://xxx.xxx.com/?code=4/0AX4XfWj-pzsABnvgQve51vVWJKC9N99d5Q4ReM6OXUYNas8pow2Ts1KDqR6qfY-MFPU8dQ&scope=https://www.googleapis.com/auth/androidpublisher

3. 找到地址中的 code 参数,注意:参数有效期很短,如果失效后重复步骤1,在示例中参数为:4/0AX4XfWj-pzsABnvgQve51vVWJKC9N99d5Q4ReM6OXUYNas8pow2Ts1KDqR6qfY-MFPU8dQ

4.向 https://accounts.google.com/o/oauth2/token发送post请求,请求 携带参数:

grant_type=authorization_code
code=<the code from the previous step>
client_id=<the client ID token created in the APIs Console>
client_secret=<the client secret corresponding to the client ID>
redirect_uri=<the URI registered with the client ID>

在示例中:

curl -X POST -d 'grant_type=authorization_code&code=$(code)&client_id=${client_id}&client_secret=${client_secret}&redirect_uri=${redirect_uri}' https://accounts.google.com/o/oauth2/token 

或用请求工具:

请求成功后即可获取 refresh_token

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值