public async Task GetAuthenticatedWebClientUsingAppOnlyAuthenticationAsync_TenantIdRequired() { var appId = "appId"; var clientCertificate = new X509Certificate2(@"Certs\testwebapplication.pfx", "password"); try { var client = await BusinessClientExtensions.GetAuthenticatedWebClientUsingAppOnlyAuthenticationAsync( new BusinessAppConfig { ActiveDirectoryAppId = appId, ActiveDirectoryClientCertificate = clientCertificate, ActiveDirectoryServiceResource = serviceResourceId, }, serviceResourceId, /* tenantId */ null, this.credentialCache.Object, this.httpProvider.Object); } catch (OneDriveException exception) { Assert.AreEqual(OneDriveErrorCode.AuthenticationFailure.ToString(), exception.Error.Code, "Unexpected error thrown."); Assert.AreEqual("Tenant ID is required for app-only authentication.", exception.Error.Message, "Unexpected error thrown."); throw; } }
public async Task GetAuthenticatedWebClientUsingAppOnlyAuthenticationAsync_ClientCertificateRequired() { var appId = "appId"; var siteId = "site_id"; var tenant = "tenant"; try { var client = await BusinessClientExtensions.GetAuthenticatedWebClientUsingAppOnlyAuthenticationAsync( new BusinessAppConfig { ActiveDirectoryAppId = appId, ActiveDirectoryServiceResource = serviceResourceId, }, siteId, tenant, this.credentialCache.Object, this.httpProvider.Object); } catch (OneDriveException exception) { Assert.AreEqual(OneDriveErrorCode.AuthenticationFailure.ToString(), exception.Error.Code, "Unexpected error thrown."); Assert.AreEqual("ActiveDirectoryClientCertificate is required for app-only authentication.", exception.Error.Message, "Unexpected error thrown."); throw; } }