I'm trying to implement authentication for Google Drive:
https://google-developers.appspot.com/drive/auth/web-server
1st, it's not obvious when the user is redirected to the Google login page to authenticate. It doesn't appear they are showing that part.
2nd, it doesn't show the call back code. I think I can figure that out and will need to add a new servlet or service or EntryPoint, but might be tricky with GWT.
3rd, and most important, I keep getting a ClassNotFoundException even though the class exists and it compiles fine.
Caused by: java.lang.NoClassDefFoundError: com/google/api/client/http/HttpRequestInitializer
at com.onix.sdm.server.SDMServiceImpl.loginServer(SDMServiceImpl.java:37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.appengine.tools.development.agent.runtime.Runtime.invoke(Runtime.java:115)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:561)
... 40 more
Caused by: java.lang.ClassNotFoundException: com.google.api.client.http.HttpRequestInitializer
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at com.google.appengine.tools.development.IsolatedAppClassLoader.loadClass(IsolatedAppClassLoader.java:215)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 47 more
It is dying on this line:
37 DriveAuthentication da = new DriveAuthentication(); // Same as MyClass
So how do you add Google Oauth2 into GWT?
GWT is a client technology, but the link you posted is for server auth. So the first step is to decide which method you want to use.
If you want server auth, then the link you posted is correct and GWT will know nothing about it. Your GWT app will call you server using RPC/REST etc, and your server will do the Drive access.
On the other hand, if you want to do client auth, then you'll need this link https://developers.google.com/accounts/docs/OAuth2UserAgent which describes the URLs you need to post to. My recommendation is to stay away from the libraries, and understand and send the raw URLs yourself.