protected static void UsingTenantContext(Action<ClientContext> action)
 {
     var auth = new AppOnlyAuthenticationTenant();
     using(var context = auth.GetAuthenticatedContext())
     {
         action(context);
     }
 }
Example #2
0
        public void AuthenticationCanUseAuthenticatedClientContextFromConfig()
        {
            var appOnlyAuth = new AppOnlyAuthenticationTenant();
            using (var ctx = appOnlyAuth.GetAuthenticatedContext())
            {
                var web = ctx.Web;
                ctx.Load(web);
                ctx.ExecuteQuery();
                Assert.IsNotNull(web.Title);
            }

            using (var ctx = appOnlyAuth.GetAuthenticatedContext())
            {
                var web = ctx.Web;
                ctx.Load(web);
                ctx.ExecuteQuery();
                Assert.IsNotNull(web.Title);
            }          
        }