I try to validate my mobile users purchases on the server, as described in https://developer.android.com/google/play/billing/billing_best_practices
I'm facing the infamous error "The project id used to call the Google Play Developer API has not been linked in the Google Play Developer Console."
After lots of digging on SO, Google, ... and still having the problem, I ask for your help.
So here is my setup :
I've downloaded a JSON key from the Google Developers Console
I'm running the following Kotlin code
Code :
compile 'com.google.http-client:google-http-client-gson:1.25.0'
compile 'com.google.apis:google-api-services-androidpublisher:v3-rev30-1.25.0'
val httpTransport = GoogleNetHttpTransport.newTrustedTransport()
val jsonFactory = GsonFactory.getDefaultInstance()
val applicationName = "MYAPP"
val packageName = "my.package"
val json = "copy/paste json key here"
val credential = GoogleCredential.fromStream(StringInputStream(json), httpTransport, jsonFactory)
.createScoped(listOf((AndroidPublisherScopes.ANDROIDPUBLISHER)))
val publisher = AndroidPublisher.Builder(httpTransport, jsonFactory, credential)
.setApplicationName(applicationName)
.build()
val productId = "product_id"
val userPurchaseToken = "a_token"
val get = publisher.purchases()
.products()
.get(packageName, productId, userPurchaseToken)
val purchase = get.execute()
Logger.getLogger("Payment user").info("Found google purchase item ${purchase.toPrettyString()}")
And then I get the exception
com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
{
"code": 403,
"errors": [
{
"domain": "androidpublisher",
"message": "The project id used to call the Google Play Developer API has not been linked in the Google Play Developer Console.",
"reason": "projectNotLinked"
}
],
"message": "The project id used to call the Google Play Developer API has not been linked in the Google Play Developer Console."
}
at com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:150)
at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:113)
at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:40)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest$1.interceptResponse(AbstractGoogleClientRequest.java:321)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1067)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:419)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:352)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:469)
Note that I've waited 24 hours and still have the same error.
- the very strange thing is that I manage to list the APKs with the code sample at https://github.com/googlesamples/android-play-publisher-api/blob/master/v3/java/src/com/google/play/developerapi/samples/ListApks.java
I'm totally lost here ...
Why do my key works for listing the APKs but does not work to validate a purchase ?
EDIT : added step 5