中查询的完整url
我正在运行gwt-oauth和谷歌联系人API的问题。我使用gwt-oauth登录,一切正常。在运行RPC检索联系人时,我得到
WARNING: Authentication error: Unable to respond to any of these challenges: {}
java.lang.NullPointerException: No authentication header information
下面是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());
}
});
}
});
这里是服务器端联系人:
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工作正常…任何想法?
解决。Auth中的联系人范围设置为:https://www.google.com/m8/feeds/contacts/default/full/显然,这不再工作,我只是设置https://www.google.com/m8/feeds/为验证以及在ContactService