subscribe with google, how to retrive expiration's date from SubscriptionToken

67 Views Asked by At

When a user registers with google for our services, the following information is saved in the DB: Key SubscriptionToken and username.

we don't know the expiration's date of the subscription. So I want to create a batch in c# that every night extract the expiration date for each user registered with google. I found this is the api to invoke

click the link for accessing it.

with this code i create a valid access_token:

string getAccessToken()
{
    scope = "https://www.googleapis.com/auth/androidpublisher";
    var _pathJson = @"C:\temp\abiding-ripple-277822-c95186b1968a.json";
    var json = File.ReadAllText(_pathJson);
    var cr = JsonConvert.DeserializeObject<PersonalServiceAccountCred>(json);
    var credential = new ServiceAccountCredential(new ServiceAccountCredential.Initializer(cr.client_email)
        {Scopes = new[] {scope}}.FromPrivateKey(cr.private_key));
    var accessToken = credential.GetAccessTokenForRequestAsync().Result;
    return accessToken;
}

but in the api test page i get this error 403 forbidden:

{
  "error": {
    "code": 403,
    "message": "The project id used to call the Google Play Developer API has not been linked in the Google Play Developer Console.",
    "errors": [
      {
        "message": "The project id used to call the Google Play Developer API has not been linked in the Google Play Developer Console.",
        "domain": "androidpublisher",
        "reason": "projectNotLinked"
      }
    ]
  }
}

what do i have to do to link the project in the Google Play Developer Console?

0

There are 0 best solutions below