2013-05-31 54 views
1

我試圖運行下面的代碼:聯繫SDK目錄API,谷歌Apps腳本

var oAuthConfig = UrlFetchApp.addOAuthService("name"); 
oAuthConfig.setRequestTokenUrl("https://www.google.com/accounts/OAuthGetRequestToken?scope=https://www.googleapis.com/auth/admin.directory.user"); 
oAuthConfig.setAuthorizationUrl("https://www.google.com/accounts/OAuthAuthorizeToken"); 
oAuthConfig.setAccessTokenUrl("https://www.google.com/accounts/OAuthGetAccessToken"); 
oAuthConfig.setConsumerKey("******************"); 
oAuthConfig.setConsumerSecret("******************"); 


var options = 
    { 
     "oAuthServiceName" : "name", 
     "oAuthUseToken" : "always", 
    }; 


var result = UrlFetchApp.fetch("https://www.googleapis.com/admin/directory/v1/users?domain=******************&maxResults=2",options); 

}

我敢肯定,我使用了「密鑰」和「消費者密鑰「 對。

的錯誤是:

{ 
"error": { 
"errors": [ 
{ 
"domain": "usageLimits", 
"reason": "dailyLimitExceededUnreg", 
"message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.", 
"extendedHelp": "https://code.google.com/apis/console" } 
] 
, 
"code": 403, 
"message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup." } 
} 

任何人都知道如何解決它?

回答

2

您需要在UrlFetchApp.fetch中發送Auth令牌作爲參數。 由於您沒有發送未認證的消息,