private TokenResponse AcquireV1WebAppAppOnlyAccessTokenByCert()
        {
            try
            {
                FileStream certFile  = File.OpenRead(textBox_Page05_CertPath.Text);
                byte[]     certBytes = new byte[certFile.Length];
                certFile.Read(certBytes, 0, (int)certFile.Length);
                var cert = new X509Certificate2(certBytes, textBox_Page05_CertPass.Text, X509KeyStorageFlags.Exportable | X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet);

                string resource = Util.ConvertResourceNameToUri(comboBox_Page05_Resource.SelectedItem.ToString());

                ClientAssertionCertificate cac = new ClientAssertionCertificate(textBox_Page05_ClientID.Text, cert);
                AuthenticationContext      authenticationContext = new AuthenticationContext("https://login.microsoftonline.com/" + textBox_Page05_TenantName.Text, false);

                AuthenticationResult authenticationResult = null;

                string errorMessage = null;
                try
                {
                    authenticationResult = authenticationContext.AcquireTokenAsync(resource, cac).Result;
                }
                catch (AdalException ex)
                {
                    errorMessage = ex.Message;
                    if (ex.InnerException != null)
                    {
                        errorMessage += "\nInnerException : " + ex.InnerException.Message;
                    }
                }
                catch (ArgumentException ex)
                {
                    errorMessage = ex.Message;
                }

                if (!string.IsNullOrEmpty(errorMessage))
                {
                    MessageBox.Show(errorMessage, "Office365APIEditor", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(null);
                }
                else
                {
                    return(Util.ConvertAuthenticationResultToTokenResponse(authenticationResult));
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Office365APIEditor", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(null);
            }
        }