1

Admin ADK Directory API ドキュメントの関連ページをすべて読み、stackoverflow に関するいくつかの質問を読みましたが、まだ行き詰っています。

グループを作成するために、Google Apps Script (Google スプレッドシートのスクリプト エディター内でコンテナーにバインド) を使用しようとしています。私は Google Apps ドメインの特権管理者であり、スクリプトは私として実行されます。

これまでに Script Editor で行ったことは次のとおりです。

  1. Resources - Advanced Google Services... - Admin Directory API をオンにしました

  2. 以下の Google Developers Console のリンクをクリックし、Admin SDK を有効にしました。

  3. ユーザーの電子メール署名を設定するために使用する作業コードを取得しました (これは、このブログ投稿から改作され、代わりにグループを作成するために変更されました:

    function createGroupTest() {
    
      var t = new Date();
      t = t.getTime();
    
      createGroup("AAA Test Group " + t, "aaa.testgroup." + t + "@mydomain.com" , "test@mydomain.com", "test");
    
    }
    
    function createGroup(groupName,groupEmail,owner,description) {
    
      var requestBody = '{"email": "'+groupEmail+'","name": "'+groupName+'","description": "'+description+'"}';
    
      var scope="https://www.googleapis.com/auth/admin.directory.group";
      var fetchArgs=googleOAuth_("Groups",scope);
      fetchArgs.method="POST";
      fetchArgs.contentType="application/json";
      fetchArgs.payload=requestBody;
    
      var url = 'https://www.googleapis.com/admin/directory/v1/groups';
    
      UrlFetchApp.fetch(url, fetchArgs);
    
    }
    
    
    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'};
    }
    

それを実行すると、次の応答が返されます。

Request failed for returned code 403. Truncated server response: { "error": { "errors": [ { "domain": "usageLimits", "reason": "dailyLimitExceededUnreg", "message": "Daily Limit for Unauthentica... (use muteHttpExceptions option to examine full response) (line 60, file "Main")

fetchArgs.muteHttpExceptions=true;エラー出力を追加すると、 Failed to authenticate for service: Groups.

4

1 に答える 1

0

理解した:

  1. リソースに移動 - 高度な Google サービス...
  2. Google Developers Console のリンクをクリックした
  3. サイドバーの資格情報セクションをクリックした
  4. [パブリック API アクセス] の下の [新しいキーの作成] をクリックしました
  5. クリックされたブラウザキー
  6. URL 文字列の末尾に「?key=」を追加し、その後に生成したキーを追加しました

したがって、完全な URL 文字列は次のようになります。

var url = 'https://www.googleapis.com/admin/directory/v1/groups?key=XXXXXXXXXXX-XXXXXXXXXXXXX-XXXXXXXXXXXXX';
于 2014-06-24T22:25:50.030 に答える