Question

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?

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top