我正在尝试运行以下代码:
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." }
}
任何人都知道如何修复它?
答案 0 :(得分:2)
您需要在UrlFetchApp.fetch中将Auth Token作为参数发送。 由于您没有发送,因此发送了未经身份验证的消息。