【问题标题】:How to access data of domain user from administrator account via google apps script如何通过谷歌应用脚​​本从管理员帐户访问域用户的数据
【发布时间】:2012-09-21 11:51:20
【问题描述】:

我无法从该用户的管理员帐户访问域用户的数据...我尝试在下面的 url 下制作 google docs 域用户的存档: 'https://docs.google.com/feeds/[userName]/private/archive'

和这个 url 来获取域用户的联系方式: https://www.google.com/m8/feeds/contacts/[userName]/full"

但它不起作用...请给出一些建议或其他解决方案。

for contacts, code is :
 function getContacts(user){
      var scope = 'https://www.google.com/m8/feeds/';
      //oAuth
      user="user@yourdomain.com"

      var fetchArgs = googleOAuth_('contacts', scope);
      var url = scope +'contacts/'+ user+'/full?v=3&alt=json';
      var urlFetch = UrlFetchApp.fetch(url, fetchArgs);
    }

    //--------------------------------------------------------------------------------------
    //Google oAuth
    //Used by getDocuments(user)
    function googleOAuth_(name,scope) {
      var oAuthConfig = UrlFetchApp.addOAuthService(name);
      oAuthConfig.setRequestTokenUrl("https://www.google.com/accounts/OAuthGetRequestToken?scope="+scope);
      oAuthConfig.setAuthorizationUrl("https://www.google.com/accounts/OAuthAuthorizeToken");
      oAuthConfig.setAccessTokenUrl("https://www.google.com/accounts/OAuthGetAccessToken");
      oAuthConfig.setConsumerKey(consumerKey);
      oAuthConfig.setConsumerSecret(consumerSecret);
      return {oAuthServiceName:name, oAuthUseToken:"always", method: "GET"};
    }

【问题讨论】:

标签: google-apps-script


【解决方案1】:

我编写了一些代码,它使用 Google Docs 原生 API 来访问用户的提要。你可以在这里查看。 https://sites.google.com/site/appsscripttutorial/urlfetch-and-oauth/get-the-document-list-of-a-domain-user

同样的概念可以扩展到你在问题中提出的其他目标

【讨论】:

  • 我尝试了这个概念来获取用户的联系人,但它给出了错误。请求返回代码 403 失败。
  • @Rishi,你是对的。我采用了相同的方法,但它不适用于联系人。我在 oAuth2.0 Playground (developers.google.com/oauthplayground) 尝试过。它适用于文档,但不适用于联系人。我不确定为什么。您可以将其发布到 Google Contacts API 论坛。
  • 这方面有什么进展吗,有问题吗?我刚刚尝试了@Rishi 的script,但它似乎仍然无法正常工作。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-08-27
  • 2013-04-29
  • 1970-01-01
  • 2014-08-13
相关资源
最近更新 更多