/// <summary> /// Instantiate a new instance of the base repo. /// </summary> /// <param name="config">The configuration object.</param> protected BaseRepo(GraphUtilConfig config) { var app = ConfidentialClientApplicationBuilder .Create(config.AppId) .WithTenantId(config.TenantId) .WithClientSecret(config.Secret) .Build(); credential = new ClientSecretCredential(config.TenantId, config.AppId, config.Secret); client = new GraphServiceClient(credential); domains = client.Domains.Request().GetAsync().Result; }
private async Task <string> GetDomainValue(string tenantId) { GraphServiceClient client = MgmtSession.Instance.ClientFactory.CreateGraphServiceClient() as GraphServiceClient; client.AuthenticationProvider = new GraphAuthenticationProvider(tenantId); IGraphServiceDomainsCollectionPage data = await client.Domains.Request().GetAsync(CancellationToken).ConfigureAwait(false); List <Domain> domains = new List <Domain>(data.CurrentPage); while (data.NextPageRequest != null) { data = await data.NextPageRequest.GetAsync(CancellationToken).ConfigureAwait(false); domains.AddRange(data.CurrentPage); } return(domains.Single(x => x.IsInitial.Value).Id); }
public async Task <List <Models.Domain> > GetDomainsAsync() { try { IGraphServiceDomainsCollectionPage domains = await graphClient.Domains.Request().GetAsync(); List <Models.Domain> values = new List <Models.Domain>(); foreach (Domain domain in domains.CurrentPage) { Models.Domain value = new Models.Domain() { Id = domain.Id, IsDefault = domain.IsDefault.HasValue ? domain.IsDefault.Value : false }; values.Add(value); } return(values); } catch { throw; } }