0

I'm running an issue with gwt-oauth and Google contacts API. I use gwt-oauth to login and everything works fine. While running the RPC for retrieving the contacts I get

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

Here is the code in Client

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());
                }
            });
        }
    });

And here the serverside for contacts:

    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;

This was working couple of weeks ago... I assume is not a scope issue since loginDetails works properly... Any idea?

Berna
  • 35
  • 1
  • 5

1 Answers1

0

Solved. Scope for contacts in Auth was set to: https://www.google.com/m8/feeds/contacts/default/full/ Apparently this doesn't work anymore and I just set https://www.google.com/m8/feeds/ for auth and the full url for querying in ContactService

Berna
  • 35
  • 1
  • 5
  • are you sure this is part of the google-api-java-client ? I do not see contacts in this list : https://code.google.com/p/google-api-java-client/wiki/APIs; Or is this the old GDATA protocol ? – koma May 14 '13 at 08:13
  • It's GDATA, you're right. Apparently there is no support for Contacts API in google-api-java-client. – Berna May 15 '13 at 08:54