locked
How to pass token while calling EWS endpoint using proxy generated classes (ExchangeServicePortTypeClient) not through EWSManagedAPI RRS feed

  • Question

  • Hello,

    I am having a console application which uses Exchange Web Services OnPrem using proxy generated classes like below

    var client = new ExchangeServicePortTypeClient("EndPointConfigName", ".XXXXX.asmx");

    It works fine. Now I want to do the same for Exchange Online but with that it's OAuth authentication and requires token to pass.

    I am generating token using registered application id, tenant id and certificate however, not sure how exactly I can add it with "ExchangeServicePortTypeClient" object.

    I see ExchangeServicePortTypeClient has some token specific properties but not getting how exactly I can do.

    Due to that I am getting exception "The HTTP request is unauthorized with client authentication scheme 'Negotiate'. The authentication header received from the server was 'Basic Realm=""'".

    I believe i would need some changes in my binding(tried both basichhttpbinding and wshttpbinding) as well but not getting what would work for OAuth authentication. 

    Just sample. I tried with all the possible options like Windows, Basic, None, Certificate...

     <security mode="Transport">
                <transport clientCredentialType="Windows" proxyCredentialType="Basic" realm="*" />
                <message clientCredentialType="UserName" algorithmSuite="Default" />
              </security>

    Can you please suggest how I can achieve this ?

    Please note I am able to do this using EWSManagedAPI as well as Service call using "HttpWebRequest" [passing token like getFolderRequest.Headers.Add("Authorization", "Bearer " + accessToken);]

    However, my requirement is to do using proxy generated classes.


    Thanks,


    ManojPatel

    Tuesday, December 1, 2020 9:20 AM

All replies

  • Exchange server related forum migrated to mentioned below link please use this

    https://docs.microsoft.com/en-us/answers/index.html

    if issue resolve please mark as answer and and vote

    Wednesday, December 2, 2020 7:15 PM
  • Thanks, that's specifically for exchange server specific general queries. This is correct forum for the exchange server development specific queries. 

    I have already raised there earlier. 

    https://docs.microsoft.com/en-us/answers/questions/180611/how-to-pass-token-while-calling-ews-endpoint-using.html

    Thanks,


    ManojPatel

    Thursday, December 3, 2020 6:41 PM