简体   繁体   English

GWT和AppEngine中的Google Oauth2

[英]Google Oauth2 in GWT and AppEngine

I'm trying to implement authentication for Google Drive: 我正在尝试对Google云端硬盘实施身份验证:

https://google-developers.appspot.com/drive/auth/web-server 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. 首先,将用户重定向到Google登录页面进行身份验证并不明显。 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. 我想我可以弄清楚,并且需要添加一个新的servlet或服务或EntryPoint,但是使用GWT可能有些棘手。

3rd, and most important, I keep getting a ClassNotFoundException even though the class exists and it compiles fine. 第三,也是最重要的一点,即使该类存在并且可以正常编译,我仍会收到ClassNotFoundException。

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? 那么如何将Google Oauth2添加到GWT中呢?

GWT is a client technology, but the link you posted is for server auth. GWT是一种客户端技术,但是您发布的链接用于服务器身份验证。 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. 如果您需要服务器身份验证,那么您发布的链接是正确的,GWT对此一无所知。 Your GWT app will call you server using RPC/REST etc, and your server will do the Drive access. 您的GWT应用程序将使用RPC / REST等调用您的服务器,并且您的服务器将进行云端硬盘访问。

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. 另一方面,如果要进行客户端身份验证,则需要此链接https://developers.google.com/accounts/docs/OAuth2UserAgent ,其中描述了您需要发布到的URL。 My recommendation is to stay away from the libraries, and understand and send the raw URLs yourself. 我的建议是远离库,自己了解并发送原始URL。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM