Monday 15 September 2014

proxy - Using Android Purchase Status API -


I have an Android application and is using this library billing play under the "Google Apps to purchase in-app" gone.

I have read that it is better to verify the purchase in backend server using the Purchase Status API (Google Play Android Developer API v1.1).

I have to use an access token, and how API is found in about an example of how to get the latest token, how to use it.

  System.getProperties (). Put ("http.proxyHost", "10.12 .54.8"); System.getProperties (). Put ("http.proxyPort", "8080"); HTTP Transportation HTTP_TRANSPORT = New Net HTP Transport (); JasonFactory JSON_FACTORY = New Jacksonfactor (); Token Response Token Response = New Token Response (); TokenResponse.setAccessToken (accessToken); TokenResponse.setRefreshToken (refreshToken); TokenResponse.setExpiresInSeconds (3600L); TokenResponse.setScope ("https://www.googleapis.com/auth/androidpublisher/v1.1/applications"); TokenResponse.setTokenType ("carrier"); HttpRequestInitializer credentials = 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, credentials) .setApplicationName (GOOGLE_PRODUCT_NAME) .build (); Buy AndroidPublisher.Inapppurchases = publisher.inapppurchases (); Get = buycs.get (GOOGLE_PACKAGE_NAME, ITEM_ID, Purchase Token); InappPurchase Purchase = get.execute ();   

But I am not able to connect to Google, perhaps because I am behind a proxy How to configure proxy settings when I do not know how to use these classes

Received error is:.

java.net.SocketTimeoutException: Timeout Connected

Please help!

I have found a solution.

Instead NetHttpTransport, use of such ApacheHttpTransport:

  HttpHost proxy = new HttpHost ( "10.12.54.8", 8080, "http"); HTTP Client Client = New DefaultHttpClient (); Client.getParams () SetParameter (ConnRoutePNames.DEFAULT_PROXY, Proxy); ApacheHttpTransport HTTP_TRANSPORT = New ApacheHttpTransport (Client);   

Now I am getting a different error (404 not found), but this is a different issue.

No comments:

Post a Comment