Reputation: 604
Im trying to get information about subscriptions purchased through our Android application but keep getting this responso via this link
https://www.googleapis.com/androidpublisher/v1/applications/[package]/subscriptions/[product id]/purchases/[subscription id]?access_token=[access token]
I've have activate the API in the API console and created a web application client id
Then I've Allow and copied the given 'code' paramtere from this link
https://accounts.google.com/o/oauth2/auth?scope=https://www.googleapis.com/auth/androidpublisher&response_type=code&access_type=offline&approval_prompt=force&redirect_uri=http://localhost&client_id=[client id]
And getting the refresh token and access token (and in this storing the refresh token for later usage) via php from our server
Getting the refresh token $url = "https://accounts.google.com/o/oauth2/token";
$post_fields = array(
"grant_type" => "authorization_code",
"code" => urldecode($code),
"client_id" => $client_id,
"client_secret" => $client_secret,
"redirect_uri" => urldecode($redirect_uri));
Getting the access token
$url = "https://accounts.google.com/o/oauth2/token";
$post_fields = $fields = array(
"grant_type" => "refresh_token",
"client_id" => $client_id,
"client_secret" => $client_secret,
"refresh_token" => $refresh_token);
$content = get_content($url, $post_fields);
Both calls are done with as a POST request
function get_content($url, $post_fields) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_MAXREDIRS, 5);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
My question is why I'm still getting this response from Google
{
"error": {
"errors": [
{
"domain": "androidpublisher",
"reason": "developerDoesNotOwnApplication",
"message": "This developer account does not own the application."
}
],
"code": 401,
"message": "This developer account does not own the application."
}
}
Upvotes: 3
Views: 602
Reputation: 93
We had the same problem. From what I know I can say that this problem occurs when you generate a refresh_token from an account that doesn't own the application (is not the owner). So you have to do it from the owner account and it will work.
Upvotes: 1