Open MaxAndolini opened 3 years ago
How are you instantiating your http transport implementation for the API client?
We suggest that you use either GoogleNetHttpTransport.newTrustedTransport()
or GoogleApacheHttpTransport.newTrustedTransport()
. These 2 helpers create HttpTransport
instances that use include trusted keys for Google APIs.
Example:
HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();
JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();
GoogleCredentials googleCredentials = GoogleCredentials.create(access_token); // replace with your auth method
HttpRequestInitializer requestInitializer = new HttpCredentialsAdapter(googleCredentials);
Storage storage = new Storage.Builder(httpTransport, jsonFactory, requestInitializer)
.setApplicationName("MyProject-1234")
.build();
How are you instantiating your http transport implementation for the API client?
We suggest that you use either
GoogleNetHttpTransport.newTrustedTransport()
orGoogleApacheHttpTransport.newTrustedTransport()
. These 2 helpers createHttpTransport
instances that use include trusted keys for Google APIs.Example:
HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport(); JsonFactory jsonFactory = JacksonFactory.getDefaultInstance(); GoogleCredentials googleCredentials = GoogleCredentials.create(access_token); // replace with your auth method HttpRequestInitializer requestInitializer = new HttpCredentialsAdapter(googleCredentials); Storage storage = new Storage.Builder(httpTransport, jsonFactory, requestInitializer) .setApplicationName("MyProject-1234") .build();
Thank you for your response. I am using it like this;
OkHttpService service = new OkHttpService(); // Firstly, I am getting credentials.json with okhttp3. Because of its here.
SubscriptionPurchase purchase = new AndroidPublisher.Builder(new NetHttpTransport(), JacksonFactory.getDefaultInstance(),
new HttpCredentialsAdapter(GoogleCredentials.fromStream(service.sendRequestInput(config.CREPATH + "credentials.json", null)).
createScoped(AndroidPublisherScopes.ANDROIDPUBLISHER))).setApplicationName(String.valueOf(R.string.app_name)).
build().purchases().subscriptions().
get(BuildConfig.APPLICATION_ID, subscriptionID, token).execute();
Changed it to this as you said;
OkHttpService service = new OkHttpService();
SubscriptionPurchase purchase = new AndroidPublisher.Builder(GoogleNetHttpTransport.newTrustedTransport(), JacksonFactory.getDefaultInstance(),
new HttpCredentialsAdapter(GoogleCredentials.fromStream(service.sendRequestInput(config.CREPATH + "credentials.json", null)).
createScoped(AndroidPublisherScopes.ANDROIDPUBLISHER))).setApplicationName(String.valueOf(R.string.app_name)).
build().purchases().subscriptions().
get(BuildConfig.APPLICATION_ID, subscriptionID, token).execute();
Still the same.
Changing to feature request for improved documentation.
I am using androidpublisher and oauth2. Because of them, I think my app removed from playstore. I gave all the necessary info below the link. What can I do?
https://stackoverflow.com/questions/65491217/how-can-i-find-and-fix-my-android-apps-security-vulnerability?noredirect=1#comment115787447_65491217