1

第一次发帖很抱歉有任何格式问题。

我正在尝试通过 oauth 下载辅助域用户的文档并收到 com.google.gdata.util.AuthenticationException: Unauthorized 错误。我可以使用与此类似的提要调用来拉取用户文档:

String docUrl = "https://docs.google.com/feeds/" + DOC_OWNER + "/private/full/" + DOC_ID + "?xoauth_requestor_id="+ PRIMARY_ADMIN_EMAIL
DocumentListEntry googleDoc = docServ.getEntry(new URL(docUrl), DocumentListEntry.class);
String exportUrl = ((MediaContent) googleDoc.getContent()).getUri().toString();
exportString = ((MediaContent) googleDoc.getContent()).getUri().split("&xoauth_requestor_id=")[0];
exportString + EXPORT_TYPE // add export type

但是当尝试下载文档时,例如:

MediaContent mc = new MediaContent();
mc.setUri(exportUrl);
String mcUrl = mc.getUri() + "&xoauth_requestor_id=" + DOC_OWNER;
MediaSource ms = docServ.getMedia(mc);

这会引发身份验证异常。我已尝试为主域管理员换出请求者 ID,但没有成功。我还尝试使用主域管理员的用户凭据,这会引发服务禁止异常。有人有什么建议吗?

4

1 回答 1

0

By default, the domain's OAuth key/secret don't have access to secondary domains. You need to manually enter the key (primary domain) and the Docs API scopes:

https://docs.google.com/feeds/,https://docs.googleusercontent.com/,https://spreadsheets.google.com/feeds/

at:

https://www.google.com/a/cpanel/YOUR-DOMAIN-HERE/ManageOauthClients

for it to work with secondary domain accounts.

于 2012-11-23T22:18:34.323 回答