step-by-step
step-by-step

Reputation: 321

Access Denied exception when using google-api-java-client

I am trying to use google-api-java-client for OAuth2.0 to create a simple 3rd party app to access an OAuth2.0 based webservices.

The programs breaks when I try to initialize

private static final HttpTransport HTTP_TRANSPORT = new ApacheHttpTransport();

They are imported as:

import com.google.api.client.http.HttpTransport;

import com.google.api.client.http.apache.ApacheHttpTransport;

It is a simple Web Application Project using Google App Engine plugin inside Eclipse.

Caused by: java.security.AccessControlException: access denied (java.net.NetPermission getProxySelector) at java.security.AccessControlContext.checkPermission(AccessControlContext.java:376) at java.security.AccessController.checkPermission(AccessController.java:549) at java.lang.SecurityManager.checkPermission(SecurityManager.java:532) at com.google.appengine.tools.development.DevAppServerFactory$CustomSecurityManager.checkPermission(DevAppServerFactory.java:383) at java.net.ProxySelector.getDefault(ProxySelector.java:73) at com.google.api.client.http.apache.ApacheHttpTransport.newDefaultHttpClient(ApacheHttpTransport.java:157) at com.google.api.client.http.apache.ApacheHttpTransport.(ApacheHttpTransport.java:100) at com.mytest.demo.TestApiDemoServlet.(TestApiDemoServlet.java:17)

I am using App Engine 1.8.4 and google-api-java-client 1.16.0-rc

Any help would be greatly appreciated!

Upvotes: 0

Views: 857

Answers (1)

Suvoraj Biswas
Suvoraj Biswas

Reputation: 673

You can't use ApacheHttpTransport in the GAE environment as this is retricted. This is the reason it is failing. You need to use UrlFetchTransport instead and it should work. To use this you need to import the corresponding jars from this link directly and drop in your libs or jar folder-

https://code.google.com/p/google-http-java-client/wiki/Setup#google-http-client-appengine

Upvotes: 1

Related Questions