2012-09-21 35 views
1

我無法從管理帳戶用戶的訪問域用戶的數據...我嘗試下面的網址,使谷歌文檔域用戶的歸檔: 'https://docs.google.com/feeds/[userName]/private/archive'如何從管理員帳戶通過谷歌訪問域用戶的數據應用腳本

和此網址可獲取域用戶的聯繫人詳情: https://www.google.com/m8/feeds /聯繫人/ [用戶名] /滿」

但它不工作...請給一些建議,或者一些其他的解決方案來做到這一點。

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

     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"}; 
    } 
+0

見下面就如何檢索目錄聯繫人答案:http://webapps.stackexchange.com/a/35880/ 29140 –

回答

1

我已經編寫了一些使用Google Docs本機API訪問用戶提要的代碼。你可以在這裏查看。 https://sites.google.com/site/appsscripttutorial/urlfetch-and-oauth/get-the-document-list-of-a-domain-user

同樣的概念可以擴展到做你問你的問題的其他目標

+0

我試圖用這個概念來獲取用戶的聯繫人,但它會給出錯誤。 請求失敗,返回碼403 – Rishi

+0

你可以分享你的代碼,這樣我可以嘗試在我結束 –

+0

我已經更新了我上面的代碼..... – Rishi

相關問題