Last active
August 27, 2022 17:46
-
-
Save tac-ljustiniano/69a374543c953d0206078dc22d094d22 to your computer and use it in GitHub Desktop.
Connecting to Google
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Google.Apis.Auth.OAuth2; | |
using Google.Apis.Admin.Directory.directory_v1; | |
using Google.Apis.Admin.Directory.directory_v1.Data; | |
using Google.Apis.Services; | |
... | |
string[] extScopes = { | |
DirectoryService.Scope.AdminDirectoryUserReadonly, | |
DirectoryService.Scope.AdminDirectoryGroupMemberReadonly | |
}; | |
... | |
// JSON Example | |
GoogleCredential credential; | |
//cert: Attached Private Key File fileInfo.BinData | |
using (var stream = new MemoryStream(cert)) | |
{ | |
credential = GoogleCredential.FromStream(stream) | |
.CreateScoped(extScopes)); | |
} | |
credential = credential.CreateWithUser(AccessAccountEmail); | |
_ds = new DirectoryService(new BaseClientService.Initializer() | |
{ | |
HttpClientInitializer = credential, | |
ApplicationName = appName | |
}); | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment