Google .json Credentials API Auth .
.json , , .
:
using Google.Apis.Services // for BaseClientServiceusing Google.Apis.Util.Store // for FileDataStoreusing System.Threading // for CancellationToken.Noneusing System.Reflection // for accessing the embedded resource of the json fileUsing Google.Apis.Auth.OAuth2- google; , Google.Apis.Calendar Google.Apis.Gmail .
:
UserCredentials credentials;
CalendarService calendarService
, Google API:
try
{
GoogleWebAuthorizationBroker.Folder = "Tasks.Auth.Store";
credentials = await GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load({file name or stream}).Secrets,
new[] {
GmailService.Scope.GmailCompose,
CalendarService.Scope.Calendar,
Google.Apis.Plus.v1.PlusService.Scope.UserinfoEmail },
"user", CancellationToken.None,
new FileDataStore("AppDataFolderName"));
} ...
.json , try/catch using (var cryptoStream = Encryption.ReadJson()) block followed by GoogleClientSecrets.Load(cryptoStream).Secrets, , .
gmail, Google, , G +.
, API- Google Developers Console.
, . :
calendarService = new CalendarService(new BaseClientService.Initializer()
{
HttpClientInitializer = credentials,
ApplicationName = "My Application"
});
.
, , . , Google | Daimto