Exemplo n.º 1
0
 public async Task GetAllUsers()
 {
     // construct the client.
     using (var contentGateClient = new ContentGateClient(baseUrl, new ContentGateCredentials(clientId, authority, deviceCodeAuthenticator)))
     {
         await contentGateClient.Users.GetUsersAsync().ConfigureAwait(false);
     }
 }
Exemplo n.º 2
0
        public async Task DeleteUser()
        {
            // construct the client.
            using (var contentGateClient = new ContentGateClient(baseUrl, new ContentGateCredentials(clientId, authority, deviceCodeAuthenticator)))
            {
                // The id of the user to be deleted.
                var id = long.Parse("## USER ID ##");

                // send the request to Content Gate.
                await contentGateClient.Users.DeleteUserAsync(id).ConfigureAwait(true);
            }
        }
Exemplo n.º 3
0
        public async Task AddRoleToUser()
        {
            // construct the client.
            using (var contentGateClient = new ContentGateClient(baseUrl, new ContentGateCredentials(clientId, authority, deviceCodeAuthenticator)))
            {
                // The id of the user to add the specified role to.
                var id = long.Parse("## USER ID ##");

                // The id of the role to be added to the user.
                string roleId = "## ROLE ID ##"; // Fill in the id of the role, e.g. 5fc81f09-a85c-4a43-813f-24de37fd7e6d

                // send the request to Content Gate
                await contentGateClient.Users.AddRoleAsync(id, roleId);
            }
        }
        public ContentGateClientFactory()
        {
            // the base uri that references the Content Gate tenant.
            var baseUrl = new Uri("## TENANT ##"); // fill in the tenant. (e.g. https://axtension.content-gate.com)

            // the client id of the app registered in the tenant.
            var clientId = "## CLIENT ID##"; // fill in the client id here. (e.g. 1bd5690d-2902-4400-b7bb-d292691e6323)

            // the authority that ContentGate belongs to, and accepts signed tokens of.
            var authority = "## AUTHORITY ##"; // fill in the authority here. (e.g. https://login.microsoftonline.com/axtension.com)

            // for device authentication, simply use the default console output to instruct the user
            // how to authenticate.
            var deviceCodeAuthenticator = DeviceAuthentication.Console;

            // construct the client.
            this._contentGateClient = new ContentGateClient(baseUrl, new ContentGateCredentials(clientId, authority, deviceCodeAuthenticator));
        }
Exemplo n.º 5
0
        public async Task UpdateUser()
        {
            // construct the client.
            using (var contentGateClient = new ContentGateClient(baseUrl, new ContentGateCredentials(clientId, authority, deviceCodeAuthenticator)))
            {
                // Define the user to be updated.
                var user = new UpdateUser
                {
                    Id          = long.Parse("## USER ID ##"),
                    FirstName   = "## FIRST NAME ##",
                    LastName    = "## LAST NAME ##",
                    DisplayName = "## DISPLAY NAME ##",
                };

                // send the request to Content Gate.
                await contentGateClient.Users.UpdateUserAsync(user).ConfigureAwait(false);
            }
        }
Exemplo n.º 6
0
        public async Task CreateUser()
        {
            // construct the client.
            using (var contentGateClient = new ContentGateClient(baseUrl, new ContentGateCredentials(clientId, authority, deviceCodeAuthenticator)))
            {
                // Define the user to be created.
                var user = new User
                {
                    FirstName   = "## FIRST NAME ##",
                    LastName    = "## LAST NAME ##",
                    DisplayName = "## DISPLAY NAME ##",
                    UserName    = "******",        // e.g. [email protected]
                    UserId      = "## AZURE AD USER ID ##" // the id of the user in Azure AD, e.g. 50780F85-1C7A-4959-A4AD-DFF6B161E1A7
                };

                // send the request to Content Gate.
                await contentGateClient.Users.CreateUserAsync(user).ConfigureAwait(false);
            }
        }
Exemplo n.º 7
0
        public async Task StartUpload()
        {
            // the base uri that references the Content Gate tenant.
            var baseUrl = new Uri("## TENANT ##"); // fill in the tenant. (e.g. https://axtension.content-gate.com)

            // the client id of the app registered in the tenant.
            var clientId = "## CLIENT ID##"; // fill in the client id here. (e.g. 1bd5690d-2902-4400-b7bb-d292691e6323)

            // the authority that ContentGate belongs to, and accepts signed tokens of.
            var authority = "## AUTHORITY ##"; // fill in the authority here. (e.g. https://login.microsoftonline.com/axtension.com)

            // for device authentication, simply use the default console output to instruct the user
            // how to authenticate.
            var deviceCodeAuthenticator = DeviceAuthentication.Console;

            // construct the client.
            using (var contentGateClient = new ContentGateClient(baseUrl, new ContentGateCredentials(clientId, authority, deviceCodeAuthenticator)))
            {
                // construct the upload manifest for uploading content.
                var addContentArgs = new AddContentArgs
                {
                    // add the binary content (or weblink content) that needs to be uploaded.
                    Assets =
                    {
                        // use binary assets to upload files.
                        new BinaryAsset("My Binary Title",      "text/plain",            @"d:\example1.txt"),

                        // use uri link assets to upload web links.
                        new UriLinkAsset("AXtension home page", "http://axtension.com"),

                        // use binary link assets to add files that already exist in the given storage provider.
                        new BinaryLinkAsset("My Binary Title",  "example1.txt")
                    },

                    // set the content category that the content will be added to.
                    ContentCategory = new ContentCategoryRef(2),

                    // set the storage provider that will store the content.
                    StorageProvider = new StorageProviderRef("AZBLOB3"),

                    // set property values that need to be set.
                    UserProperties =
                    {
                        // set user property values by adding a user property id and its corresponding value.
                        new UserPropertyValue {
                            Property = new UserPropertyRef(1), Value = "Remarks"
                        },
                        new UserPropertyValue {
                            Property = new UserPropertyRef(2), Value = DateTime.Now
                        },
                    },

                    // add the connection to one or more business entities.
                    Connections =
                    {
                        // externally linked business entity reference (using external reference) which means:
                        // business entity connector reference, external type, external id combination
                        BusinessEntityRef.ExternalReference("DYN3652", "Customers", "CustomerAccount='US-027',dataAreaId='usmf'")
                    }
                };

                // send the request to Content Gate.
                await contentGateClient.Content.AddContentAsync(addContentArgs).ConfigureAwait(false);
            }
        }