嗨,我正在使用 java 并试图检索域中的所有用户,因为我使用了 Provisionin api............它工作得很好但我的想法是使用 2-legged OAuth 来检索域中的用户是否可能?我不知道如何指定网址请帮帮我我尝试了以下程序
final String CONSUMER_KEY = "example.com";
final String CONSUMER_SECRET = "12345678122154154df9";
final String DOMAIN = "example.com";
GoogleOAuthParameters oauthParameters = new GoogleOAuthParameters();
oauthParameters.setOAuthConsumerKey(CONSUMER_KEY);
oauthParameters.setOAuthConsumerSecret(CONSUMER_SECRET);
oauthParameters.setOAuthType(OAuthType.TWO_LEGGED_OAUTH);
OAuthHmacSha1Signer signer = new OAuthHmacSha1Signer();
URL feedUrl = new URL("https://apps-apis.google.com/a/feeds/" + DOMAIN +
"/user/2.0/?xoauth_id=123@example.com");
userService = new UserService("Myapplication");
userService.setOAuthCredentials(oauthParameters, signer);
userService.useSsl();
UserFeed allUsers = new UserFeed();
UserFeed allpage;
Link nextLink;
do {
allpage = userService.getFeed(feedUrl, UserFeed.class);
allUsers.getEntries().addAll(allpage.getEntries());
nextLink = allpage.getLink(Link.Rel.NEXT, Link.Type.ATOM);
if (nextLink != null) {
feedUrl = new URL(nextLink.getHref());
}
}while (nextLink != null);
return allUsers;
}
将错误返回为 com.google.gdata.util.AuthenticationException: Unknown authentication header