+1 vote
by (200 points)
retagged by

I've followed the sample given here -http://blog.rebex.net/howto-authenticate-gmail-rebex-oauth/. I'm trying to setup an outlook email account. I'm successfully able to get the access token.

var client= new Smtp();
client.Connect("smtp-mail.outlook.com", SslMode.Explicit);

token here is base64 -encoded string , just like you've shown for gmail. ( Ref - https://msdn.microsoft.com/en-IN/library/dn440163.aspx )

Login statement throws this exception -
{Rebex.Net.SmtpException: OAuth failed: OAuth authentication failed due to Invalid token. Code -2147184118 (535).
at Rebex.Net.Smtp.JRR(String T, String R, SmtpAuthentication J, GssApiProvider C)
at Rebex.Net.Smtp.JG(String T, String R, SmtpAuthentication J)
at Rebex.Net.Smtp.Login(String token, SmtpAuthentication method)

Please note that I'm trying to do this for @outlook account and not office 365. I've tried this with - smtp.live.com as well but no luck.

I've passed these scopes for authentication - https://outlook.office.com/Mail.ReadWrite https://outlook.office.com/Mail.Send openid profile.

Please let me know if I'm missing anything here?

Also, If you could also provide information on the following things -
1. Is there a future plan to provide support for Gmail REST API , Outlook REST API to send mails
2. Giving SSL.Implicit for Outlook doesn't work. Any reason for it?

Any inputs are appreciated. Thank you!

by (58.9k points)
SMTP details for the live.com SMTP server is:
port = 587
explicit TLS

with Rebex SMTP just write the following:
            var smtp = new Smtp();
            smtp.Connect("smtp-mail.outlook.com", SslMode.Explicit);
by (58.9k points)
As to the Oauth2.0 authentication to outlook.com/live.com servers.
I've found the following tutorial https://msdn.microsoft.com/en-us/library/dn440163.aspx

According to the above tutorial, the scopes that you said (Mail.ReadWrite and Mail.Send)you requested does not seem to be supported at all. Maybe this is the problem? See possible scopes and permissions at https://msdn.microsoft.com/en-us/library/hh243646.aspx
by (200 points)
Thanks Tomas. There were 2 issues :
I was calling new end point(https://login.microsoftonline.com/common/oauth2/v2.0/authorize) with the mentioned scopes for access token. I'd to use deprecated Live Connect APIs(login.live.com) and need to pass wl.imap scope for smtp access.
by (70.2k points)
If I understand it correctly. You were able to make it working?
by (200 points)
Yes, this is working perfectly fine with outlook. Thanks.
by (58.9k points)

1 Answer

0 votes
by (58.9k points)
edited by

I have summarized the findings about getting the OAuth 2.0 access tokens with Yahoo and Outlook.com mail servers.

See http://forum.rebex.net/6674/authenticate-yahoo-and-outlook-com-email-servers-with-oauth for more details.

Update: We published a blog post that describes how to login with OAuth 2.0 to Office365 with Rebex Secure Mail, and another one that describes how to register application for with appropriate permissions in Azure.