exchange: 401: Unauthorized

Last post 02-06-2012, 1:30 AM by babar.raza. 9 replies.
Sort Posts: Previous Next
  •  01-10-2012, 7:56 PM 354267

    exchange: 401: Unauthorized

    I can't seem to connect with EWS and Office365.  This used to work.  I know the credentials and the URLs are good because I can authenticate and see services.wsdl in a browser for both BPOS and Office365.Using Microsoft.Exchange.Webservices library works fine for both URLs

    The BPOS url+credentials work fine, but the Office365+credentials (which are valid) do not.  The following exception occurs whenever I try to use the auto discovered Office365 URL, and it occurs on the line requesting the inbox uri (basically the first web operation):
    The request failed with HTTP status 401: Unauthorized.

    using Aspose.Email.Exchange;
    using Aspose.Email.Mail;

    namespace testauth2
    {
        class Program
        {
            static void Main(string[] args)
            {
                x x = new x();
                x.y();
            }
            class x
            {
                ExchangeWebServiceClient client_aspose;
                public void y()
                {
                    string url_bpos = "https://red001.mail.microsoftonline.com/ews/exchange.asmx";
                    string url_o365 = "https://********.outlook.com/EWS/Exchange.asmx";//obtained using auto discover
                    client_aspose = new ExchangeWebServiceClient(url_o365, "********@*********.***", "*********");
                    string inboxUri = client_aspose.MailboxInfo.InboxUri;
                    ExchangeMessageInfoCollection items = client_aspose.ListMessages(inboxUri, 100);
                    MailMessage mm = client_aspose.FetchMessage(items[0].UniqueUri);
                }
            }
        }
    }


     
  •  01-11-2012, 4:24 AM 354344 in reply to 354267

    Re: exchange: 401: Unauthorized .NET

    Hi,

    We are sorry for your inconvenience.

    The message you are receiving, points out that your are either providing the wrong URL or the wrong credentials. As you have confirmed both to be correct, can you please test your scenario with latest version of Aspose.Email for .NET v1.3.0

    In case your problem persists with latest version then you need to share the URL and credentials so we may reproduce the said issue on our end. It is better to arrange a test account for few days (till the issue is rectified). Please share the sensitive information via a private message. You can send a private message/email by clicking the "Contact" button on this thread and selecting "send babar.raza an email". 

    Looking forward to your response. 

    Babar Raza
    Support Developer,
    Aspose Sialkot Team
    http://www.aspose.com/
    Aspose - Your File Format Experts
     
  •  01-12-2012, 1:01 PM 354763 in reply to 354344

    Re: exchange: 401: Unauthorized

    Hi,

    Thank you for providing us the test account details. 

    I can connect to Outlook365 using Aspose.Email for .NET v1.3.0. Please check the below source code for your reference. 

    C#
          string mailboxURI = "https://********.outlook.com/EWS/Exchange.asmx";       var username = "****@*****.com";       var password = "*****";       var domain = "";       NetworkCredential credential = new NetworkCredential(username, password, domain);       ExchangeWebServiceClient client = new ExchangeWebServiceClient(mailboxURI, credential);

          ExchangeMessageInfoCollection items = client.ListMessages("Inbox", 10);

    Please give it a try at your end and let us know of your feedback. 

    Babar Raza
    Support Developer,
    Aspose Sialkot Team
    http://www.aspose.com/
    Aspose - Your File Format Experts
     
  •  01-12-2012, 9:40 PM 354808 in reply to 354763

    Re: exchange: 401: Unauthorized

    using 1.3.0 net3.5

    Length cannot be less than zero.
    Parameter name: length

    happens when trying to use the line

    ExchangeMessageInfoCollection items = client_aspose.ListMessages("Inbox", 100);


    edit:  I copied your code exactly and am still getting that exception when at the line:

    ExchangeMessageInfoCollection items = client.ListMessages("Inbox", 10);

     
  •  01-13-2012, 5:22 AM 354910 in reply to 354808

    Re: exchange: 401: Unauthorized .NET

    Hi,

    Thank you for your response.

    I have encountered the same problem, so I have logged an investigative ticket in our tracking system to probe further into this matter. The ticket Id for your reference NETWORKNET-33125. We will keep you posted with updates on this.

    Regards,

    Babar Raza
    Support Developer,
    Aspose Sialkot Team
    http://www.aspose.com/
    Aspose - Your File Format Experts
     
  •  01-25-2012, 10:38 AM 357229 in reply to 354910

    Re: exchange: 401: Unauthorized

    I'm sorry to have to ask this, but what progress have you made towards solving this problem?
     
  •  01-25-2012, 11:25 AM 357249 in reply to 357229

    Re: exchange: 401: Unauthorized .NET

    Hi Matthew,

    Thank you for your patience.

    We have fixed the issue logged under ticket Id NETWORKNET-33125. The fix will be published with the next major release of Aspose.Email for .NET v1.4.0, that is scheduled for the 5th week of 2012. 

    Once the new version is available for public us, you will be notified via this thread.

    Babar Raza
    Support Developer,
    Aspose Sialkot Team
    http://www.aspose.com/
    Aspose - Your File Format Experts
     
  •  02-01-2012, 3:06 PM 358773 in reply to 354267

    Re: exchange: 401: Unauthorized

    The issues you have found earlier (filed as NETWORKNET-33125 ) have been fixed in this update.


    This message was posted using Notification2Forum from Downloads module by aspose.notifier.
     
  •  02-02-2012, 2:06 PM 359038 in reply to 357249

    Re: exchange: 401: Unauthorized

    I'm afraid that while using the 1.4.0.0 release, the exception still happens when trying to use the function ListMessages.

    ArgumentOutOfRangeException
    Length cannot be less than zero.
    Parameter name: length


    string mailboxURI = "https://****************************************";
    var username = "******@********.com";
    var password = "********";
    var domain = "";
    NetworkCredential credential = new NetworkCredential(username, password, domain);
    ExchangeWebServiceClient client = new ExchangeWebServiceClient(mailboxURI, credential);
    ExchangeMessageInfoCollection items = client.ListMessages("Inbox", 10);


    Do you still have the test credentials and url that we prepared for you to debug with?


    P.S.  The Error 401 unauthorized no longer happens, so that IS fixed, but the exception when listmessages remains.

    P.P.S.  When using the correct method of ListMessages it works (retrieve inbox uri) when using your suggested method of just using "inbox" the exception happens.  So actually the confusion is due to you telling me to use your broken example because the unbroken working way to do it is:

    string inboxUri = client_aspose.MailboxInfo.InboxUri;
    ExchangeMessageInfoCollection items = client_aspose.ListMessages(inboxUri, 100);

    and the bad way to do it is:

    ExchangeMessageInfoCollection items = client.ListMessages("Inbox", 10);



    so after all the bugs are all fixed.

     
  •  02-06-2012, 1:30 AM 359371 in reply to 359038

    Re: exchange: 401: Unauthorized .NET

    Hi Matthew,

    Thank you for your feedback and apologies for your inconvenience. 

    According to my knowledge both below mentioned source code lines should produce the same result. For a confirmation, I have logged your comments to the ticket already associated with this thread. 

    C#
    var messages = client.ListMessages(client.GetMailboxInfo().InboxUri);
    var messages = client.ListMessages("Inbox");

    Also, I am getting the ArgumentOutOfRangeException on the second source code line, so I am waiting for a feedback from the development end on this. 

    Babar Raza
    Support Developer,
    Aspose Sialkot Team
    http://www.aspose.com/
    Aspose - Your File Format Experts
     
View as RSS news feed in XML