小编use*_*714的帖子

Google Docs API - 模拟用户文件下载

将Google Docs Java API与Google Apps帐户一起使用,是否可以冒充用户并下载文件?

当我运行下面的程序时,它显然登录到域并模拟用户,因为它检索其中一个文件的详细信息并打印出文件标题.但是,当它尝试下载文件时,会抛出ServiceForbiddenException.

如果Java API无法实现,是否有人知道我的程序是否可以使用Protocol API编写HTTP请求来下载文件?

public class AuthExample {

private static DocsService docService = new DocsService("Auth Example");

public static void main(String[] args)
    throws Exception
{
    String adminUser = args[0];
    String adminPassword = args[1];
    String authToken = args[2];
    String impersonatedUser = args[3];

    loginToDomain(adminUser, adminPassword, authToken);

    URL url = new URL( "https://docs.google.com/feeds/" + impersonatedUser + "/private/full" );
    DocumentListFeed feed = docService.getFeed(url, DocumentListFeed.class);

    DocumentListEntry entry = feed.getEntries().get(0);

    String title = entry.getTitle().getPlainText();
    System.out.println( title );

    String type = entry.getType();
    if …
Run Code Online (Sandbox Code Playgroud)

google-docs google-docs-api google-data-api

6
推荐指数
1
解决办法
742
查看次数