1

I'm coding an Android native application that contains subscriptions purchases.
I have a problem with the Purchases.subscriptions: get service of the Google Play Developer API.

Here's my code :

            TokenResponse tokenResponse = new TokenResponse();
            tokenResponse.setAccessToken(ACCESS_TOKEN);
            tokenResponse.setRefreshToken(REFRESH_TOKEN);
            tokenResponse.setExpiresInSeconds(3600L);
            tokenResponse.setScope("https://www.googleapis.com/auth/androidpublisher");
            tokenResponse.setTokenType("Bearer");

            HttpRequestInitializer credential =  new GoogleCredential.Builder().setTransport(HTTP_TRANSPORT)
                    .setJsonFactory(JSON_FACTORY)
                    .setClientSecrets(GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET)
                    .build()
                    .setFromTokenResponse(tokenResponse);

            AndroidPublisher publisher = new AndroidPublisher.Builder(HTTP_TRANSPORT, JSON_FACTORY, credential).
                    setApplicationName("MyApp").
                    build();

            AndroidPublisher.Purchases purchases = publisher.purchases();
            AndroidPublisher.Purchases.Subscriptions.Get get = purchases.subscriptions().get("com.myapp.app.android", mSubscriptionId, mPurchaseToken);

            SubscriptionPurchase subscripcion = get.execute();



When i'm in debug mode, this part of the code works perfectly and the Subscriptions.Get service respond OK with the detail json that correspond to the parameter mPurchaseToken
Example of URL service on the app logs in debug mode :

DetailSubs: http : https://www.googleapis.com/androidpublisher/v3/applications/com.myapp.app.android/purchases/subscriptions/sub_1_month/tokens/[mPurchaseToken]





But when i test the app with a Generated Signed APK, the Subscriptions.Get service doesn't work and i have this stacktrace :

 System.err: d.e.c.a.b.d.b: 404 Not Found
 W System.err: Not Found
 I System.out: [CDS]close[45832]
 I System.out: close [socket][/0.0.0.0:45832]
 W System.err:    at d.e.c.a.b.f.d.b.a()
 W System.err:    at d.e.c.a.b.f.d.b.a()
 W System.err:    at d.e.c.a.b.f.b$a.a()
[...]

Example of URL service on the app logs in "Signed APK" mode :

DetailSubs: http : https://www.googleapis.com/androidpublisher/v3/applications//purchases/subscriptions//tokens/?m=sub_1_month

Can you help me to find the source of this anomaly please ?

Thanks for your help.

EDIT :

Moreover, i use this version of the "Google Play Developer API V3" library :

compile 'com.google.apis:google-api-services-androidpublisher:v3-rev129-1.25.0'
Franck DM
  • 11
  • 2
  • you have to slashes in the second url, //purchases and //tokens, is that intentional and could be that part of the reason? – Erti-Chris Eelmaa Dec 14 '19 at 22:56
  • @Erti-Chris Eelmaa thanks for your comment. Yes, i also think this is the reason why there are an "404 Not Found" error. But the URL is generated by the code in my post and the // are not intentional. I don't understand why this works in debug mode and not with a signed APK with the same parameters. – Franck DM Dec 15 '19 at 15:10

0 Answers0