After successful manifest upload, I am now struggling with getting the access token using Office JS API. I have followed the instructions but without luck so far.
The error I am getting is 13001 - the user is not signed in Office. However its clear that I am logged into Office 365 since I am running the add-in from Outlook Online.
Code:
function showDialog() {
getDataWithToken({ forceConsent: false });
Office.context.ui.displayDialogAsync('https://localhost:3000/PluginApp/index.html',
{ height: 80, width: 80, displayInIframe: true}, function(asyncResult) {
// ... code
});
function getDataWithToken(options) {
Office.context.auth.getAccessTokenAsync(options,
function (result) {
debugger;
if (result.status === "succeeded") {
//TODO1: Use the access token to get Microsoft Graph data.
}
else {
handleClientSideErrors(result);
}
});
}
function handleClientSideErrors(result) {
switch (result.error.code) {
case 13001:
getDataWithToken({ forceAddAccount: true });
break;
}
}
print screen below:
Additional answers:
2) In my manifest file I have defined the ExecuteFunction to run the method when user clicked on addin. I am not using the taskpane since the width is too small. I would like to open a dialog to have more space to render the stuff. So therefore I cant get the info before the dialog is opened since I am getting possibly sensitive information so thats why the whole code is after opening of dialog.
3) My company uses primary Office 365 account. The setup is hybrid (on premise AD and cloud mailboxes. data is synced via DirSync).

