Calling an azure function from outlook web addin (to generate tokens), works in outlook web but its failing from outlook desktop

Viewed 21

I'm trying to create an event driven outlook web addin and need to call an Azure function. Using Ajax to call the Azure Function and it works as expected from outlook web (have added the CORS exception on the Azure function app).

But the same fails when the addin is running in outlook desktop. Could some one please suggest the right way to implement this for outlook desktop client.

function GenerateGraphToken()
  {
    console.log('in GenerateGraphToken')
    var token='';
    var serviceURL = "https://xxxxxxxxxxx.azurewebsites.net/api/Function1";
 
    $.ajax({
      url: serviceURL,
      type: "GET",
      async:false,
      beforeSend: function (xhr) {
        xhr.setRequestHeader('x-functions-key', 'xxxxxxxxxxxxx');
    },
      crossDomain: true,
      success: function (data) {
        //token = data;
        localStorage.clear();
        localStorage.setItem("token", data);
        //console.log("Success: " + data);
      },
      error: function (ex) {
        console.log("Failure getting user token");
    }
  });
    return token;
  }
0 Answers
Related