How do I authenticate with the Play Purchase Status API using OAuth 2.0?
I am using the Play Purchase Status API to help reconcile expiration of
in-app subscriptions. Specifically I am trying to match the
"validUntilTimestampMsec" up against recorded statuses that are managed
via IAB notifications. I am following the Authorization instructions here:
https://developers.google.com/android-publisher/authorization, but I am
wondering how to use the access and refresh tokens. After you get an
access and refresh token pair that looks like this:
{
"access_token" : "ya29.ZStBkRnGyZ2mUYOLgls7QVBxOg82XhBCFo8UIT5gM",
"token_type" : "Bearer",
"expires_in" : 3600,
"refresh_token" : "1/zaaHNytlC3SEBX7F2cfrHcqJEa3KoAHYeXES6nmho"
}
It shows how to access.
Once you have an access token, you can make calls to the API by appending
the token as a query parameter:
https://www.googleapis.com/androidpublisher/v1/...?access_token=...
I believe Play Purchase Status API needs to have v1.1 instead of v1, and
the rest of the first ellipsis is specific to what you are doing. The
second ellipsis setting the access_token is unclear to me whether it
should be the JSON containing the access/refresh pair or simply the access
token attribute of that JSON object. I am also curious as to whether this
pair stays persistent. On my back-end I want to pass a request to check a
subscription status. My PHP code simply builds the URL for the GET
request, and I attempt to use file_get_contents( $reqUrl ) where $reqUrl
is the url.
If I add the access_token URL parameter to the end of my URL query string,
should that work indefinitely, or should my code be generating new access
and refresh tokens each time it is about to call the API? Help in
answering these questions is much appreciated!
No comments:
Post a Comment