none
Loading apps for office addin from outlook 2013 - Getting Access Denied error but when trying to load the addin from OWA its working fine RRS feed

  • Question

  • I have simple requirement here to fetch data from Exchange Online EWS API and display those data onto HTML page of Apps for Office. This office app should work on OWA (Web mail) as well as Outlook client. I am able to see the data in browser (using OWA - Web mail), but when I am trying to load the same add-in on outlook client(i.e Apps for Office icon) it doesn't show the data and gives the error in errorMessage as:

    No Transport.

    So, we did try enabling the CORS using $.support.cors = true as per this thread, but no luck with that and got Access Denied error.

    Does anyone have found the solution for this kind of scenario. Any help would be much appreciated.

    Below is code snippet where I am getting that error:

    $.ajax({
        url: "https://myazuretenant.azurewebsites.net/GetData.asmx/GetDetails",
        type: "POST",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (data) {
             // Data Manipulation goes here
        },
        error: function (data, errorCode, errorMessage) {
            app.showNotification('Error: ' + errorCode + ' - ' + errorMessage);
        }
    });


    Tuesday, November 17, 2015 7:11 AM

All replies

  • Hi Sandip,

    Is the request in above in the same domain with the web application for Outlook add-in? If not, this error is expected since we are not able to make a common AJAX request cross the domain.

    To achieve the goal, we need to overcome same-origin policy enforcement when we develop add-ins, we can:

    • Use JSON/P for anonymous access.

    • Implement server-side script using a token-based authentication scheme.

    • Using cross-origin resource sharing (CORS).

    • Build your own proxy using IFRAME and POST MESSAGE.

    You can get more detail about this topic from link below:
    Addressing same-origin policy limitations in Office Add-ins

    >>So, we did try enabling the CORS using $.support.cors
    = true
     as per this thread, but no luck with that and got Access Denied error.<<

    $.support.cors contains the result of a test that tests whether or not the current browser supports CORS. changing it doesn't make the browser support CORS. To enable CORS, we need to require a single response header to be sent by the server.

    You can find more detail for CORS in the above link.

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, November 18, 2015 6:52 AM
    Moderator
  • Hi Fei,

    Thanks for the reply .

    When I run the same ajax post on browser(i.e. in OWA - outlook webmail), it gives me proper response. While with Outlook Client, it is giving the error on $.ajax post request error function and returns Access Denied error.

    Does that mean Cross Domain issue occurs in Outlook Client only and not in OWA - outlook webmail? (**Note** - ASMX web service is hosted on Azure web app).

    I did all the settings for CORS - in web.config file  & in Home.js file also. still getting "Access Denied" error.

    web.config - settings

    <httpProtocol>
      <customHeaders>
       <add name="Access-Control-Allow-Origin" value="*" />
       <add name="Access-Control-Allow-Headers" value="Content-Type" />
        <add name="Access-Control-Allow-Methods" value="POST" />
      </customHeaders>
     </httpProtocol>

    Home.js - settings

    before .ajax call

     $.support.cors = true;

    In .ajax post request

    crossDomain: true,

    Below is the screenshot.

    Outlook Client

    Thank you.


    Wednesday, November 18, 2015 7:25 AM
  • Hi Sandip,

    >>Does that mean Cross Domain issue occurs in Outlook Client only and not in OWA - outlook webmail? (**Note** - ASMX web service is hosted on Azure web app).<<

    No. The Cross Domain issues always occur when we make a AJAX request cross the domain.

    And if the CORS was enabled on the server, there is no need addition steps to make a AJAX request. We can use the script as normal to request a AJAX request as normal request.

    I suggest that you make a normal web page and send a AJAX cross domain request to get the HTTP response headers to make sure the CORS settings works.

    And please make sure that if the Mail add-in used the HTPPs protocol since we are not able to make a AJAX request from HTTPs to HTTP. we can modify the web service to provide service with HTTPs protocol. This is caused by the limitation that requests must be targeted to the same scheme as the hosting page.

    You can get more detail about it from link below:
    http://blogs.msdn.com/b/ieinternals/archive/2010/05/13/xdomainrequest-restrictions-limitations-and-workarounds.aspx

    Regards & Fei



    Monday, November 23, 2015 9:37 AM
    Moderator
  • Hi,

    I has the same issue: my web outlook add-in needs to call a web api to retrieve data but it does not work on the Outlook desktop.

    At the beginning, I had the same error "Access is denied" when calling the api but after following this post, I fixed the error by applying your suggestions:

    • Enable CORS on the web api server to allow cross domain request.
    • Make sure the add-in and the web api both use HTTPS protocol.

    For now, my add-in works fine in outlook web mail (OWA) but cannot call the api from the Outlook desktop app. I don't know why.

    Please help me because I need this working for current project. Thank you.

    Tuesday, November 24, 2015 11:33 AM
  • Hi Sandi & PhucVC,

    Since I am not able to reproduce this issue, I have share the demo project from link below:
    http://1drv.ms/1P8bkpC

    You can try this project to see whether it works for the Outlook client. If the issue still occur, I suggest that you try to repair or update the Outlook to see whether it is helpful.

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, November 25, 2015 7:13 AM
    Moderator
  • Hi Fei,

    Just I would like to add my solution structure.

    I have Office App project & SharePoint Provider Hosted apps project are under one solution. Then in my provider hosted web project I have added .asmx web service. I am using that web service, to get data from both SharePoint & exchange as well  and display it in my add-in. 

    Thanks & Regards,

    Sandip

    Thursday, November 26, 2015 7:10 AM
  • Hi Sandip,

    Did you try the demo project in the preview post? And would you mind tell us what's the protocol used in the Office add-in. We can track it via the Fiddler and please ensure that you were using HTTPS in the Office add-ins.

    In addition, we can use Fiddler to send a request to the service to see whether the HTTP response contains the specific headers for CORS.

    Hope it is helpful.

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, November 27, 2015 8:07 AM
    Moderator
  • Hi Fei,

    Actually, I was tried to download the demo project, but here in my organization all links starting with http gets blocked. So, I was not able to download & test it.

    We are deploying our Office add-in on azure web site with https URL.

    Thank you.

    Regards,

    Sandip

    Wednesday, December 2, 2015 11:18 AM
  • Hi Sandip,

    I have shared the demo with HTTPS link below:
    https://onedrive.live.com/redir?resid=AF618BBEF578722D!71366&authkey=!AHKMtOtC0sZbm9A&ithint=file%2czip

    Please let me know, if you have problem with this demo project.

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, December 3, 2015 5:59 AM
    Moderator
  • Hi Fei,

    Still getting error when I am trying to open the URL shared by you. I hv tried in chrome also & getting "This Web web page is not available"

    .

    Thank you.

    Regards,

    Sandip


    Friday, December 4, 2015 5:12 AM
  • Hi Sandip,

    This issue is relative to the network issue. I suggest that you contact the IT department to fix this issue. Or you can try to share a demo project to help us understand this issue exactly.

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, December 7, 2015 6:37 AM
    Moderator