I want to use the email settings API, but can not find any documentation how to use this api with the oAuth2 authentication
- Am I using the correct API?
- Am I using the latest API? (Google.GData.Apps.dll Version 2.2.0)
- How can I use this DLl with an google console project with p12 file and serviceaccount?
According to the Google documentation this is the latest api voor email settings: https://developers.google.com/admin-sdk/email-settings/
I can not find any documentation on this page how to use it in .Net with Oauth, but in the example I see this:
using Google.GData.Apps;
using Google.GData.Apps.GoogleMailSettings;
GoogleMailSettingsService service = new GoogleMailSettingsService("yourdomain", "your-apps");
service.setUserCredentials("adminUsername", "adminPassword");
service.CreateSendAs("liz", "Sales", "[email protected]", "", "true");
So searching for these references I find this page: https://code.google.com/p/google-gdata/ or the nuget package: www.nuget.org/packages/Google.GData.Apps/ the latest version is 2.2.0
Since we are switching to the new api's using console projects Oauth2 and service-account my question is, can I use the dll also using the same authentication as for the newest api's
the new api's use this authentication method:
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("[email protected]")
{
Scopes = scopes,
User = "[email protected]"
}.FromCertificate(certificate));
// Create the service.
var service = new DirectoryService(
new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "Admin directory Provisioning Sample",
});
service.Users.Delete(userKey).Execute();
I've took the example to create the OAuth flow from the directory API https://developers.google.com/admin-sdk/directory/v1/quickstart/dotnet and used it to connect to the emailsettings api service.