B4J Question Google Play Developer API Error Code: 403

jtare

Active Member
Licensed User
Longtime User
I have a lot of question about google's api.
First I followed Erel's tutorial on how to use the Google Play Developer API (here) and I did successfully got the response of "http://127.0.0.1:51042/inventory?package=your.package.here" just like the tutorial showed.

But when I try to get the status of a user's subscription purchase(see this) with the following request:
B4X:
"https://www.googleapis.com/androidpublisher/v3/applications/[packageName]/purchases/subscriptions/[subscriptionId]/tokens/[token]"
Note: The token in the url is the token from the purchase, not the api access token.
I get this response:
B4X:
ResponseError. Reason: Forbidden, Response: {
 "error": {
  "errors": [
   {
    "domain": "androidpublisher",
    "reason": "projectNotLinked",
    "message": "The project id used to call the Google Play Developer API has not been linked in the Google Play Developer Console."
   }
  ],
  "code": 403,
  "message": "The project id used to call the Google Play Developer API has not been linked in the Google Play Developer Console."
 }

Which is very confusing and left me with a lot of questions.
What does the access token obtained from the tutorial mean? It is tied to my gmail account? If so, it means it is some sort of personal access token safe to use in a server?

I also found this (here), apperantly you can access the api with a service account (with limited access) or an Oauth client, I believe the method I tried is Oauth.
I tried to access the api with a service account (I failed), which apparently are used to access without giving your personal credentials but I ended in a very complicated tutorial which I could not follow.

Googleing this issue I found this post in stackoverflow which is actually setting up a service account, which I couldn't. This post says it can get billing information.

What I'm looking to do is to take a user's purchase token, forward it to my server and get the purchase status from my server.

Thanks in advance.
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
What does the access token obtained from the tutorial mean? It is tied to my gmail account? If so, it means it is some sort of personal access token safe to use in a server?
It is a token tied to your developer account.
Whether it is safe or not to use in a server depends on the server implementation. The token will not be sent to the client. It is sent from the server to Google severs.

Make sure that the correct project is linked in Google Play Developers console.
 
Upvote 0

jtare

Active Member
Licensed User
Longtime User
Make sure that the correct project is linked in Google Play Developers console.
I believe it is linked to the Google Play Developer Console, the client id in the console matches the one in Google APIs (api and services - credentials), because it does allow me to get the inventory:
B4X:
    j.Download("https://www.googleapis.com/androidpublisher/v2/applications/[PackageName]/inappproducts")
    j.GetRequest.SetHeader("Authorization", "Bearer " & Token)
 
Upvote 0

jtare

Active Member
Licensed User
Longtime User
Apparently I get the not linked message because my app is currently in private alpha, I just tried with another app in production and it worked perfectly.
 
Upvote 0

jtare

Active Member
Licensed User
Longtime User
What I said:
Apparently I get the not linked message because my app is currently in private alpha
Is not true. For some reason the api is woking now and my app still is on private alpha.
 
Last edited:
Upvote 0
Top