Search code examples
office365office365-appsoffice365api

Using ADAL JS Lib in JS App


I need to use the ADAL JS lib for my office 365 add-in. I went through the github page here. I saw the example is given in the form of an Angular JS App. Is there any example which can be used in plain JS app. The office add-in was created from Napa Dev tools which generates a basic skeleton and I am building the app on top of it. Do you think Angular JS would be a better option to build the outlook office add-in?

I plan to use the Outlook 365 REST APIs in the app, before doing that I need the authentication module to be working. I need to get the token so that I can pass on to the endpoint in order to execute the REST APIs.

Please correct me if my approach seems to be in the wrong direction and also let me know if more information is needed. Thanks!


Solution

  • ADAL JS was definitely built with SPAs in mind, which is why it was made with an Angular module. You really have 2 options here, depending on how comfortable with Angular you are.

    1. Build out your Add-in as an Angular app. You'll be able to use ADAL JS as it's documented here.
    2. Don't use Angular and don't use ADAL JS. It's just OAuth underneath, so you can use whatever you'd like to handle that. You can see an example on how to request an access token from Azure without Angular here.

    Good luck!