/// <summary> /// Initializes a new instance of the /// <see cref="Google.Apis.Authentication.OAuth2.DotNetOpenAuth.AssertionFlowClient"/> class. /// </summary> /// <param name='authorizationServer'> /// Authorization server description. /// </param> /// <param name='certificate'> /// Certificate to use to sign the assertion flow messages. /// </param> public AssertionFlowClient(AuthorizationServerDescription authorizationServer, X509Certificate2 certificate) : base(authorizationServer, null, null) { certificate.ThrowIfNull("certificate"); certificate.PrivateKey.ThrowIfNull("certificate.PrivateKey"); Header = new GoogleAssertionFlowHeader(); Certificate = certificate; // Workaround to correctly cast the private key as a RSACryptoServiceProvider type 24 RSACryptoServiceProvider rsa = (RSACryptoServiceProvider) certificate.PrivateKey; byte[] privateKeyBlob = rsa.ExportCspBlob(true); Key = new RSACryptoServiceProvider(); Key.ImportCspBlob(privateKeyBlob); }