public static void InitPublicClient()
        {
            var builder = PublicClientApplicationBuilder
                          .Create(ClientId)
                          .WithAuthority(new Uri(Authority), ValidateAuthority)
                          .WithLogging((level, message, pii) =>
            {
                Device.BeginInvokeOnMainThread(() => { LogPage.AddToLog("[" + level + "]" + " - " + message, pii); });
            },
                                       LogLevel.Verbose,
                                       true);

            if (UseBroker)
            {
                builder.WithBroker();
                builder = builder.WithRedirectUri(BrokerRedirectUriOnIos);
            }

            else
            {
                builder.WithRedirectUri(DefaultMobileRedirectUri);

                if (Device.RuntimePlatform == Device.iOS)
                {
                    builder = builder.WithIosKeychainSecurityGroup("com.microsoft.adalcache");
                }
            }

            MsalPublicClient = builder.BuildConcrete();
        }
        private async void CreateExceptionMessage(Exception exception)
        {
            if (exception is MsalException msalException)
            {
                var formattedMessage = string.Format(CultureInfo.InvariantCulture, "MsalException -\nError Code: {0}\nMessage: {1}",
                                                     msalException.ErrorCode, msalException.Message);
                acquireResponseLabel.Text = formattedMessage;
                LogPage.AddToLog(formattedMessage, false);
            }
            else
            {
                acquireResponseLabel.Text = "Exception - " + exception.Message;
            }

            System.Console.WriteLine(exception.Message);

            await DisplayAlert("An error occured. Check Logs", exception.Message, "OK").ConfigureAwait(false);
        }