1
votes

I'm trying to run the following code:

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);

}

I'm sure I'm using the "secret key" and "consumer key" right.

The error is:

{
 "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." }
 }

Anyone know how to fix it?

1

1 Answers

2
votes

You need to send the Auth Token as parameter in the UrlFetchApp.fetch . As you didn't send it the message of unauthenticated was sent.