google play 支付验证projectNotLinked

2016-09-14  本文已影响0人  juket

链接多个项目问题

1. 问题: connect more than one project id to the google play developer console

google play v2版本支付验证问题 :
projectNotLinked如果有多个项目 怎么链接,因为后台只能链接一个?

When I try to execute a request for a Google developer API. purchases(). products(). get() I receive a 403 error: projectNotLinked.
The message tells me "The project id used to call the Google Play Developer API has not been linked in the Google Play Developer Console."
At this point I can go to the console, unlink a previous project, and link this one, run the code, and the code works.
However, I cannot unlink permanently the previous project: I need to keep them both linked. How do I solve this problem?
I looked around and couldn't find a solution. Tried to call Google, and they told me that they do not support this kind of requests.
Thanks in advance.

2.

You can only have one project linked to your Play Developer console at a time. What you can do is try to move your credentials over to one project, so everything is contained in a single project. – Andy

3.

To reemphasise @andy's comment: There can be only one linked API project.
I spend quite some time to find this out. Google's documentation is not helpful here.
If you need access to by multiple projects/applications you can create multiple service accounts inside of the single linked API project and manages access to apps individually.

3.

Andy's comment is correct, I find the description LINKED PROJECT in the Google Play Developer Console confusing at best.
However, I setup in the Google Developers Console a company project with the appropriate Server Keys and Service accounts. It isn't ideal, but it works. You can then assign permission to the required service account back in the Google Play Developer Console.
You can also setup just one key and service account if that makes it simpler and the use them as shown below in PHP for a server

$service_account_name = 'xxxxxxxxxx-xxxxxxxxxxxxxxx@developer.gserviceaccount.com';
$key_file_location = somedir/keyfile.p12;

$client = new Google_Client();
$client->setApplicationName("GoogleDevelopersConsoleProjectName");
$service = new Google_Service_AndroidPublisher($client);

$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 = "GoogleDevelopersConsoleServerKey";
$client->setDeveloperKey($apiKey);

$package_name = "com.yourcompany.yourappname1";

Then all you need to do for the other application is change the $package_name.

$package_name = "com.yourcompany.yourappname2";

Then using the Google Service AndroidPublisher to query subscriptions

$service = new Google_Service_AndroidPublisher($client);

$results = $service->purchases_subscriptions->get($package_name,$subscriptionId,$token,array()

You can also start to assign multiple keys, service accounts and other credentials you add other projects in the Google Play Developer Console.

上一篇下一篇

猜你喜欢

热点阅读