Gwt-gdata 身份验证

发布于 2024-09-01 12:11:03 字数 2675 浏览 10 评论 0原文

我正在使用 GWT 编写一个应用程序,我在互联网上发现有一个库可以轻松使用 gdata 功能。特别是我需要使用与 Google 日历的集成。我按照 gwt-gdata 网站上的官方指南进行身份验证( http:// /code.google.com/p/gwt-gdata/wiki/GettingStarted )但不幸的是,我遇到了错误。这就是错误:

  17:59:12.463 [ERROR] [testmappa] Unable to load module entry point class testMappa.client.TestMappa (see associated exception for details)
    com.google.gwt.core.client.JavaScriptException: 
(TypeError): $wnd.google.accounts is undefined
     fileName: http://127.0.0.1:8888
     lineNumber: 29
     stack: ("http://www.google.com/calendar/feeds/")@http://127.0.0.1:8888:29
    connect("http://127.0.0.1:8888/TestMappa.html?gwt.codesvr=127.0.0.1:9997","`gL1<a3s4B&Y{(Ci","127.0.0.1:9997","testmappa","2.0")@:0
    ((void 0),"testmappa","http://127.0.0.1:8888/testmappa/")@http://127.0.0.1:8888/testmappa/hosted.html?testmappa:264
    z()@http://127.0.0.1:8888/testmappa/testmappa.nocache.js:2
    (-2)@http://127.0.0.1:8888/testmappa/testmappa.nocache.js:8
        at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:195)
        at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:120)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:507)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:264)
        at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
        at com.google.gwt.accounts.client.User.login(User.java)
        at testMappa.client.TestMappa.onModuleLoad(TestMappa.java:68)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:369)
        at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:185)
        at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:380)
        at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:222)
        at java.lang.Thread.run(Thread.java:637)

我无法理解此错误的原因。我的代码很简单:

    String scope = "http://www.google.com/calendar/feeds/";

    User.login(scope);

据我所知,它应该按原样工作。我不知道该怎么办,我来这里是想问如何解决这个问题,以及是否可以直接使用 gdata 本机 java 库,但我相信客户端 gwt 代码不可能完成这件事(因为代码将被转换为 JavaScript)。

谢谢。

I'm writing an application with GWT and I found on the internet that there's a library to use easily gdata features. In particular I need to use the integration with Google Calendar. I followed the official guide on gwt-gdata site to do the authentication ( http://code.google.com/p/gwt-gdata/wiki/GettingStarted ) but unfortunately, I got an error. This is the error:

  17:59:12.463 [ERROR] [testmappa] Unable to load module entry point class testMappa.client.TestMappa (see associated exception for details)
    com.google.gwt.core.client.JavaScriptException: 
(TypeError): $wnd.google.accounts is undefined
     fileName: http://127.0.0.1:8888
     lineNumber: 29
     stack: ("http://www.google.com/calendar/feeds/")@http://127.0.0.1:8888:29
    connect("http://127.0.0.1:8888/TestMappa.html?gwt.codesvr=127.0.0.1:9997","`gL1<a3s4B&Y{(Ci","127.0.0.1:9997","testmappa","2.0")@:0
    ((void 0),"testmappa","http://127.0.0.1:8888/testmappa/")@http://127.0.0.1:8888/testmappa/hosted.html?testmappa:264
    z()@http://127.0.0.1:8888/testmappa/testmappa.nocache.js:2
    (-2)@http://127.0.0.1:8888/testmappa/testmappa.nocache.js:8
        at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:195)
        at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:120)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:507)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:264)
        at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
        at com.google.gwt.accounts.client.User.login(User.java)
        at testMappa.client.TestMappa.onModuleLoad(TestMappa.java:68)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:369)
        at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:185)
        at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:380)
        at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:222)
        at java.lang.Thread.run(Thread.java:637)

I'm not able to understand the reason of this error. My code is simply:

    String scope = "http://www.google.com/calendar/feeds/";

    User.login(scope);

And as far as I know it should work as it is. I don't know what to do and I'm here to ask how to solve this problem and if I can directly use gdata native java library, but I believe this other thing is not possible to be done for client-side gwt code (since the code is going to be converted to javascript).

Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

半夏半凉 2024-09-08 12:11:03

您上面粘贴的两行代码实际上应该像这样出现在 run 方法中 -

if (GData.isLoaded(GDataSystemPackage.CALENDAR)) {
   Window.alert("Package is loaded");
} else {
   GData.loadGDataApi("MyApiKey",
      new Runnable() {
        public void run() {
             String scope = "http://www.google.com/calendar/feeds/";
             User.login(scope);
             //remaining code comes in here. you may create a new method
             //and call it from here.
        }
      },
      GDataSystemPackage.CALENDAR);
}

如果您不加载 GData api 代码,您可能会收到粘贴的 JavaScript 错误。

The two lines of code you pasted above should actually come within the run method like this -

if (GData.isLoaded(GDataSystemPackage.CALENDAR)) {
   Window.alert("Package is loaded");
} else {
   GData.loadGDataApi("MyApiKey",
      new Runnable() {
        public void run() {
             String scope = "http://www.google.com/calendar/feeds/";
             User.login(scope);
             //remaining code comes in here. you may create a new method
             //and call it from here.
        }
      },
      GDataSystemPackage.CALENDAR);
}

If you don't load the GData api code, you are likely to get the javascript error that you pasted.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文