Admin ADK Directory API ドキュメントの関連ページをすべて読み、stackoverflow に関するいくつかの質問を読みましたが、まだ行き詰っています。
グループを作成するために、Google Apps Script (Google スプレッドシートのスクリプト エディター内でコンテナーにバインド) を使用しようとしています。私は Google Apps ドメインの特権管理者であり、スクリプトは私として実行されます。
これまでに Script Editor で行ったことは次のとおりです。
Resources - Advanced Google Services... - Admin Directory API をオンにしました
以下の Google Developers Console のリンクをクリックし、Admin SDK を有効にしました。
ユーザーの電子メール署名を設定するために使用する作業コードを取得しました (これは、このブログ投稿から改作され、代わりにグループを作成するために変更されました:
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
.