I\'m trying to get response with an access code and getting:
XMLHttpRequest cannot load \"h...://login.microsoftonline.com/d331431b-899c-4666-8094-e82
As mythz explained in his answer, CORS is not allowed from your originating domain. You are, however, allowed to register your application with Microsoft Azure(?) Active Directory so that it can display a separate login dialog that will return a callback to your application as soon as authentication succeeds.
For more information about the AAD login flow (mind you, this is a NodeJS example, not bare javascript, but the same logic applies) check out Getting started with Azure AD.