![]() ![]() I can obtain a token using Postman (see below), but when I pass the access_token value to EWS.Login(token, EwsAuthentication.OAuth20) I get the error "OAuth token is invalid (invalid_token)". If (Verify("Test", signature, verified") Ĭonsole.WriteLine("ERROR: Signature not valid!") Ĭonsole.WriteLine("EXCEPTION: " + ex.Are there any code examples for accessing an Office 365 mailbox using EWS with an OAuth 2.0 token.Įverything is configured correct in Azure AD with regard to creating a RegisteredApp with the correct permissions. Testcert.cer corresponds to "cn=my cert subject" Return csp.VerifyHash(hash, CryptoConfig.MapNameToOID("SHA1"), signature) īyte signature = Sign("Test", "cn=my cert subject") RSACryptoServiceProvider csp = (RSACryptoServiceProvider) X509Certificate2 cert = new X509Certificate2() If we want to use the client cert in an ASP.NET app, we may use something like this instead: X509Certificate2 cert = new X509Certificate2(certPath) Load the certificate we'll use to verify the signature from a file Static bool Verify(string text, byte signature, string certPath) ![]() Return csp.SignHash(hash, CryptoConfig.MapNameToOID("SHA1")) ![]() UnicodeEncoding encoding = new UnicodeEncoding() Throw new Exception("No valid cert was found") Get its associated CSP and private keyĬsp = (RSACryptoServiceProvider)cert.PrivateKey Find the certificate we'll use to signįoreach (X509Certificate2 cert in my.Certificates) X509Store my = new X509Store(StoreName.My, StoreLocation.CurrentUser) Access Personal (MY) certificate store of current user Static byte Sign(string text, string certSubject) ![]() ASP.NET) (both will onlyhave public key associated to them). WinForms) applications or a client certificate (for i.e. Today I'm posting a sample which shows how to sign a text with a certificate in my Personal store (this cert will have public and private key associated to it) and how to verify that signature with a. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
January 2023
Categories |