I need to download my key.p12 file from https://console.cloud.google.com/ but I dont know how to do it now. My Dashboard "Api & Services > Credentials" is like this:
I need this p12 file to connect to the PHP API Google_Service_AndroidPublisher with this code (I am using the same code in this Stackoverflow answer to the question Get android subscription status, failed with 403:
$service_account_name = 'testing@nootrictesting.iam.gserviceaccount.com'; //Your service account email
$key_file_location = ''; // p12 file (key.p12)
$client = new Google_Client();
$client->setApplicationName("My name app"); //This is the name of the linked application
$key = file_get_contents($key_file_location);
$cred = new Google_Auth_AssertionCredentials(
$service_account_name,
array('https://www.googleapis.com/auth/androidpublisher'),
$key
);
$client->setAssertionCredentials($cred);
if($client->getAuth()->isAccessTokenExpired()) {
$client->getAuth()->refreshTokenWithAssertion($cred);
}
$apiKey = ""; //API key
$client->setDeveloperKey($apiKey);
$service = new Google_Service_AndroidPublisher($client);
$results = $service->purchases_subscriptions->get("MY_ANDROID_APP_PACKAGE", $product_id, $purchase_token, array());
Any help will be useful. Thanks!!!
DalmoTo linked the video in their comment that shows how/where to grab keys: youtu.be/asrCdWFrF0A?t=76
However, Google_Auth_AssertionCredentials looks like it shouldn't be used any longer (https://github.com/googleapis/google-api-php-client/blob/master/UPGRADING.md). Instead, use $client->setAuthConfig('/path/to/service-account.json')
. Then you can use the json key file, not the p12 key file.