Пример #1
0
        /// <summary>
        /// Update Redirect URIs of client application with URIs based on provided applicationUrl.
        /// </summary>
        /// <param name="applicationUrl"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task UpdateClientApplicationRedirectUrisAsync(
            string applicationUrl,
            CancellationToken cancellationToken = default
            )
        {
            if (string.IsNullOrWhiteSpace(applicationUrl))
            {
                throw new ArgumentNullException(nameof(applicationUrl));
            }

            applicationUrl = applicationUrl.Trim();

            if (!applicationUrl.StartsWith("https://") && !applicationUrl.StartsWith("http://"))
            {
                applicationUrl = $"https://{applicationUrl}";
            }

            if (!applicationUrl.EndsWith("/"))
            {
                applicationUrl += "/";
            }

            Log.Information($"Updating RedirectUris of client " +
                            $"application to point to '{applicationUrl}'");

            var redirectUris = new List <string> {
                $"{applicationUrl}registry/swagger/oauth2-redirect.html",
                $"{applicationUrl}twin/swagger/oauth2-redirect.html",
                $"{applicationUrl}history/swagger/oauth2-redirect.html",
                $"{applicationUrl}vault/swagger/oauth2-redirect.html",
                $"{applicationUrl}onboarding/swagger/oauth2-redirect.html",
                $"{applicationUrl}publisher/swagger/oauth2-redirect.html",
                $"{applicationUrl}jobs/swagger/oauth2-redirect.html",
                $"{applicationUrl}configuration/swagger/oauth2-redirect.html",
                $"{applicationUrl}edge/jobs/swagger/oauth2-redirect.html",
                $"{applicationUrl}edge/manage/swagger/oauth2-redirect.html",
                $"{applicationUrl}frontend/signin-oidc",
            };

            _clientApplication = await _msGraphServiceClient
                                 .UpdateApplicationRedirectUrisAsync(
                _clientApplication,
                redirectUris,
                cancellationToken
                );
        }
        public async Task UpdateClientApplicationRedirectUrisAsync(
            string applicationURL,
            CancellationToken cancellationToken = default
            )
        {
            if (null == applicationURL)
            {
                throw new ArgumentNullException("applicationURL");
            }

            if (applicationURL.Trim() == string.Empty)
            {
                throw new ArgumentException("Input cannot be empty", "applicationURL");
            }

            if (!applicationURL.StartsWith("https://") && !applicationURL.StartsWith("http://"))
            {
                applicationURL = $"https://{applicationURL}";
            }

            if (!applicationURL.EndsWith("/"))
            {
                applicationURL += "/";
            }

            Log.Information($"Updating RedirectUris of client " +
                            $"application to point to '{applicationURL}'");

            var redirectUris = new List <string> {
                $"{applicationURL}",
                $"{applicationURL}registry/",
                $"{applicationURL}twin/",
                $"{applicationURL}history/",
                $"{applicationURL}ua/",
                $"{applicationURL}vault/"
            };

            _clientApplication = await _msGraphServiceClient
                                 .UpdateApplicationRedirectUrisAsync(
                _clientApplication,
                redirectUris,
                cancellationToken
                );
        }