レシートの照合【Android編】


1.「Google API OAuth2.0のアクセストークン&リフレッシュトークン取得手順 2017年2月版」のrefresh_tokenが取得できるとこまで進める。

2.以下を実行してアクセストークンを取得する。

curl -v -X POST 'https://accounts.google.com/o/oauth2/token' -d 'grant_type=refresh_token&refresh_token={リフレッシュトークン}&client_id={クライアントID}.apps.googleusercontent.com&client_secret={クライアントシークレット}&redirect_uri=https://onimomo-test.firebaseapp.com/__/auth/handler'

{
  "access_token" : "ya29.XXXXXXXXXXXX",
  "expires_in" : 3600,
  "token_type" : "Bearer"
* Connection #0 to host accounts.google.com left intact
}

3.アクセストークンを使用してAPIを実行する

curl https://www.googleapis.com/androidpublisher/v1.1/applications/jp.etimestech.onimomo/inapp/{アプリのパッケージネーム}/purchases/{設定した商品名}?access_token={アクセストークン}

4.以降、アクセストークンが切れたら"2"からやり直す

参考

https://qiita.com/iwaseasahi/items/2363dc1d246bc06baeae
 Google API OAuth2.0のアクセストークン&リフレッシュトークン取得手順 2017年2月版
https://qiita.com/shin1ogawa/items/49a076f62e5f17f18fe5
 Google APIのAccess Tokenをお手軽に取得する
https://ameblo.jp/principia-ca/entry-12071725733.html
 自動購読課金について【Android編】