メール設定 API を使用したいのですが、oAuth2 認証でこの API を使用する方法に関するドキュメントが見つかりません
- 正しい API を使用していますか?
- 最新の API を使用していますか? (Google.GData.Apps.dll バージョン 2.2.0)
- この DLl を p12 ファイルとサービス アカウントを持つ Google コンソール プロジェクトで使用するにはどうすればよいですか?
Google のドキュメントによると、これは最新の api voor メール設定です: https://developers.google.com/admin-sdk/email-settings/
このページには、Oauth を使用して .Net で使用する方法に関するドキュメントはありませんが、例では次のように表示されます。
using Google.GData.Apps;
using Google.GData.Apps.GoogleMailSettings;
GoogleMailSettingsService service = new GoogleMailSettingsService("yourdomain", "your-apps");
service.setUserCredentials("adminUsername", "adminPassword");
service.CreateSendAs("liz", "Sales", "sales@example.com", "", "true");
これらの参照を検索すると、次のページが見つかります: https://code.google.com/p/google-gdata/ または nuget パッケージ: www.nuget.org/packages/Google.GData.Apps/ 最新バージョンは 2.2 です.0
コンソール プロジェクト Oauth2 とサービス アカウントを使用して新しい API に切り替えているので、私の質問は、最新の API と同じ認証を使用して dll を使用できますか?
新しい API は次の認証方法を使用します。
X509Certificate2 certificate = new X509Certificate2(@"\location\P12File.p12", "notasecret", X509KeyStorageFlags.Exportable);
IEnumerable<string> scopes = new[] { DirectoryService.Scope.AdminDirectoryUser, DirectoryService.Scope.AdminDirectoryUserSecurity };
ServiceAccountCredential credential = new ServiceAccountCredential(
new ServiceAccountCredential.Initializer("ServiceAccountEmail@domain.com")
{
Scopes = scopes,
User = "AdminAccount@domain.com"
}.FromCertificate(certificate));
// Create the service.
var service = new DirectoryService(
new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "Admin directory Provisioning Sample",
});
service.Users.Delete(userKey).Execute();