예제 #1
0
        public void InvalidConfiguration_ThrowsException()
        {
            var auth          = new ClientCredentialsAuthProvider().GetAuthentication(Configuration);
            var invalidApiUrl = Configuration.Urls.ApiUrl + "/dev/v3";
            var dokladConfig  = new DokladConfiguration(invalidApiUrl, Configuration.Urls.IdentityServerTokenUrl);
            var context       = new ApiContext("Tests", "1.0", auth, dokladConfig);
            var api           = new DokladApi(context);

            Assert.Throws <ValidationException>(() => api.ContactClient.List().Get());
        }
        // </UserGraphClientFunctions>

        // <AppGraphClientFunctions>
        public GraphServiceClient GetAppGraphClient(ILogger logger)
        {
            if (_appGraphClient == null)
            {
                // Create a client credentials auth provider
                var authProvider = new ClientCredentialsAuthProvider(
                    _config["webHookId"],
                    _config["webHookSecret"],
                    _config["tenantId"],
                    // The https://graph.microsoft.com/.default scope
                    // is required for client credentials. It requests
                    // all of the permissions that are explicitly set on
                    // the app registration
                    new[] { "https://graph.microsoft.com/.default" },
                    logger);

                _appGraphClient = new GraphServiceClient(authProvider);
            }

            return(_appGraphClient);
        }