0
大多數Google Management API似乎已啓用服務帳戶。例如,我可以檢索日曆像這樣:爲服務帳戶啓用Google羣組設置API?
string scope = Google.Apis.Calendar.v3.CalendarService.Scopes.Calendar.ToString().ToLower();
string scope_url = "https://www.googleapis.com/auth/" + scope;
string client_id = "[email protected]";
string key_file = @"\path\to\my-privatekey.p12";
string key_pass = "notasecret";
AuthorizationServerDescription desc = GoogleAuthenticationServer.Description;
X509Certificate2 key = new X509Certificate2(key_file, key_pass, X509KeyStorageFlags.Exportable);
AssertionFlowClient client = new AssertionFlowClient(desc, key) { ServiceAccountId = client_id, Scope = scope_url };
OAuth2Authenticator<AssertionFlowClient> auth = new OAuth2Authenticator<AssertionFlowClient>(client, AssertionFlowClient.GetState);
CalendarService service = new CalendarService(auth);
var x = service.Calendars.Get("[email protected]").Fetch();
然而,在GroupssettingsService相同的代碼返回一個503 - 服務器不可用。這是否意味着服務帳戶不能與該API一起使用?
在可能的相關問題,組設置服務的範圍似乎是apps.groups.settings
但如果你打電話
GroupssettingsService.Scopes.AppsGroupsSettings.ToString().ToLower();
...你appsgroupssettings
代替,而嵌入式時期。
是否有另一種方法使用服務帳戶的GroupssettingsService?或有關正確範圍字符串的任何信息?
非常感謝。
嗯,你會永遠需要的服務帳戶同樣的原因 - 允許一個可信的後端應用程序使用存儲的憑證進行更新,升級超過用戶的級別。在這種情況下,一些非超級用戶可以定義電子郵件組;該應用程序使用GData組API創建並填充組。理想情況下,它會使用Groupssettings API進行特定的策略設置(例如審覈),我不希望用戶能夠關閉該設置。 –
您只需創建一個真正的Google Apps用戶即可單獨用作服務帳戶。這當然意味着50美元/年,但這不應該考慮糟糕。用戶需要成爲超級管理員,但OAuth2令牌僅限於組設置API,因此訪問權限最小。 –
對我們來說是免費的(教育),但這仍然需要三條腿的授權。除非我錯了(我很樂意成爲),否則「服務帳戶」就是新的Google Apps API適用於雙腿授權的方式。所以我編寫了2LO訪問代碼,但是這個特定的API(Groupssettings)似乎將這些請求過濾掉了。 –