public IUserService InitUserService(string token, EventSource source) { if (token == null) { throw new Exception("API token is null"); } IUserService userService = null; switch (source) { case EventSource.Microsoft: var serviceClient = GraphClient.GetAuthenticatedClient(token); userService = new MSGraphUserService(serviceClient); break; case EventSource.Google: var googleClient = GoogleClient.GetGoogleClient(_settings); var googlePeopleClient = GooglePeopleService.GetServiceClient(googleClient, token); userService = new GooglePeopleService(googlePeopleClient); break; default: throw new Exception("Event Type not Defined"); } return(new UserService(userService)); }
private async Task Run() { var conn = await Connection.GetAuthorizationUsingCredentials(@"C:\client_secret_10.json", PeopleServiceService.Scope.Contacts); var googlePeopleService = new GooglePeopleService(conn); //var googlePeopleService = new GooglePeopleService(@"C:\secr10.p12", PeopleServiceService.Scope.Contacts, "mine.gserviceaccount.com"); var id = googlePeopleService.GetId("*****@*****.**"); }
/// <inheritdoc/> public IUserService InitUserService(string token, TimeZoneInfo timeZoneInfo, MailSource source) { switch (source) { case MailSource.Microsoft: var serviceClient = GraphClient.GetAuthenticatedClient(token, timeZoneInfo); return(new MSGraphUserService(serviceClient, timeZoneInfo)); case MailSource.Google: var googleClient = GoogleClient.GetGoogleClient(_settings); var googlePeopleClient = GooglePeopleService.GetServiceClient(googleClient, token); return(new GooglePeopleService(googlePeopleClient)); default: throw new Exception("Event Type not Defined"); } }