I'm developing an app with in-app purchases, so I want to know if subscription expired. I've already got my RefreshToken and AccessToken, but when I'm trying to get subscription info according to this, I always get the same error:
{ "error": { "errors": [
{ "domain": "global",
"reason": "authError",
"message": "Invalid Credentials",
"locationType": "header",
"location": "Authorization" } ],
"code": 401,
"message": "Invalid Credentials" }}
My code goes here:
String urlt = " https://www.googleapis.com/androidpublisher/v3/applications/" + PACKAGE_NAME + "/purchases/subscriptions/" + SUBSCR_ID + "/tokens/" + accessToken;
DefaultHttpClient client = new DefaultHttpClient();
HttpGet post = new HttpGet(urlt);
post.setHeader("Scope" , "https://www.googleapis.com/auth/androidpublisher");
post.setHeader("Authorization" , "Bearer" + accessToken);
try {
org.apache.http.HttpResponse response = client.execute(post);
BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
StringBuffer buffer = new StringBuffer();
for (String line = reader.readLine(); line != null; line = reader.readLine()) {
buffer.append(line);
}
JSONObject json = new JSONObject(buffer.toString());
int x = 0;
}
catch (Exception e) {
e.printStackTrace();
}
Please help ((