0
我正在運行gwt-oauth和Google聯繫人API的問題。 我使用gwt-oauth登錄並且一切正常。 當運行RPC檢索聯繫人,我得到Google聯繫人API問題
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工作正常... 任何想法?
你確定這是谷歌,API-的一部分java客戶端?我在此列表中看不到聯繫人:https://code.google.com/p/google-api-java-client/wiki/APIs;或者這是舊的GDATA協議? – koma 2013-05-14 08:13:13
這是GDATA,你是對的。 Google-api-java-client顯然不支持Contacts API。 – Berna 2013-05-15 08:54:32