Search Posts

For Java developer, login to microsoft api is a problem

I have developed a SharePoint library to read/write SharePoint Online restful api. As you can see the below image from Microsoft, we need to sign-in to Microsoft before we can get the access token. Access token is a value that you need to pass to every restful calls as a parameter, otherwise the restful call will return error. So far there are three way to do sign-in

  1. Hack the sign in, manually construct the xml and send it to, see line 70 , i don’t think it is a perfect way
  2. Use Microsoft graph in whatevery you want, when user browse to your page, it popup a microsoft login dialog, then user can sign in. But sometime i want to use the same credential to grab everything from SharePoint, pop user a sign-in dialog is meaningless, then you may go to point 3
  3. Use Microsoft Authentication Library Preview for JavaScript (MSAL.js) , but there is no Java library

One little skill, if you are debugging your js code, just turn on debugger. Msal library will print more debug messages on screen for you

Leave a Reply

Your email address will not be published. Required fields are marked *