0

我遇到了 gwt-oauth 和 Google 联系人 API 的问题。我使用 gwt-oauth 登录,一切正常。在运行 RPC 以检索我得到的联系人时

WARNING: Authentication error: Unable to respond to any of these challenges: {}
java.lang.NullPointerException: No authentication header information

这是客户端中的代码

Button button = new Button("Authenticate with Google");
    button.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            final AuthRequest req = new AuthRequest(K.GOOGLE_AUTH_URL, K.GOOGLE_CLIENT_ID).withScopes(K.CONTACTS_SCOPE, K.AUTH_SCOPE);
            AUTH.expiresIn(req);
            AUTH.login(req, new Callback<String, Throwable>() {
                @Override
                public void onSuccess(final String token) {
                    greetingService.loginDetails(token, new AsyncCallback<LoginInfo>() {
                        @Override
                        public void onSuccess(LoginInfo result) {

                        greetingService.getContactList(token, new AsyncCallback<Boolean>() {

                                @Override
                                public void onSuccess(Boolean result) {
                                    Window.alert("oh");
                                }

                                @Override
                                public void onFailure(Throwable caught) {
                                    Window.alert("Error:\n" + caught.getMessage());
                                }
                            });
                        }

                        @Override
                        public void onFailure(Throwable caught) {
                            // TODO Auto-generated method stub

                        }
                    });
                }

                @Override
                public void onFailure(Throwable caught) {
                    Window.alert("Error:\n" + caught.getMessage());
                }
            });
        }
    });

这里是联系人的服务器端:

    try {
        ContactsService s = new ContactsService(K.APPLICATION_NAME);
        s.setProtocolVersion(ContactsService.Versions.V3);
        s.setAuthSubToken(token);
        s.setHeader("Authorization", "Bearer " + token);
        for (ContactEntry entry : s.query(new Query(new URL(K.CONTACTS_SCOPE)), ContactFeed.class).getEntries())
            System.out.println(entry.toString());
    } catch (Exception e) {
        e.printStackTrace();
    } 
    return true;

这是几周前的工作......我认为这不是范围问题,因为 loginDetails 工作正常......知道吗?

4

1 回答 1

0

解决了。Auth 中的联系人范围设置为:https ://www.google.com/m8/feeds/contacts/default/full/ 显然这不再起作用,我只是设置了https://www.google.com/ m8/feeds/用于 auth 和用于在 ContactService 中查询的完整 url

于 2013-05-14T07:36:59.970 回答