Google支付服务端client_id和client_secret及refresh_token参数申请

版权声明:本文为博主原创文章,转载请备注,感谢。 https://blog.csdn.net/chenglinlin526/article/details/78086127

第一步:获取client_id和client_secret

登录开发账号,在API权限里面创建相应的Oauth客户端获取


第二步:获取Authorization code

https://accounts.google.com/o/oauth2/auth?scope=https://www.googleapis.com/auth/androidpublisher&response_type=code&access_type=offline&redirect_uri=http://localhost&client_id={client_id}

直接复制到浏览器地址栏回车,然后在地址栏会看到code,保存留待下一步用


第三步:获取refresh_token(是一个长效token)

<form  id="iosLoad" action="https://accounts.google.com/o/oauth2/token" method="post">
    <input  name="grant_type" value="authorization_code">
    <input  name="code" value="code">
    <input  name="client_id" value="client_id">
    <input  name="client_secret" value="client_secre">
    <input  name="redirect_uri" value="http://localhost">
    <input type="submit" value="提交">
</form>


可以放到一个jsp页面里面,点击提交获取refresh_token,得到一个JSON文件如下:

{
    "access_token": "yi02.3gC2jwm77YPkylq0H5sPJ8559JHX93Kq8qZHRMogL300XKD02125deFEPY6zg",
    "token_type": "Bearer",
    "expires_in": 3600,
    "refresh_token": "1/FbQD421215jJDHX9Kq8qCHRJaDa_M0U5WupXL_o"
}

注意 只能用post请求,另refresh_token只有第一次发起请求得到的JSON字符串中包含,以后再请求将不再出现refresh_token,宝宝们一定要把它保存好了,切记,切记,切记(重要的事情说三遍!!!)


至此服务端调用google支付api需要的参数准备完毕

猜你喜欢

转载自blog.csdn.net/chenglinlin526/article/details/78086127