0

I am trying to retrieve the Sign Info details using Office 365 graph API by passing Token to retrieve the information.

I am able to get response when i hit the url in fiddler -

"https://graph.windows.net/xxx.sharepoint.com/activities/signinEvents?api-version=beta"

But it is failing when i call using ajax with the following error

"XMLHttpRequest cannot load https://graph.windows.net/xxx.sharepoint.com/activities/signinEvents?api-version=beta. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://xxx.sharepoint.com' is therefore not allowed access. The response had HTTP status code 404."

Please help me understand what am I missing ?

nitinr708
  • 1,393
  • 2
  • 19
  • 29
  • 2
    Browsers do not allow to request data via AJAX from other domains than the one the script was loaded from unless the other website authorizes this explicitly via the `Access-Control-Allow-Origin` HTTP header. This is why your request fails. Have look at [this answer](https://stackoverflow.com/a/43715501/8362098) which explain how to use the Micrsoft Graph API with AJAX. – Christoph Böhme Aug 07 '17 at 08:20

1 Answers1

0

You need to utilize a different library perhaps, Please use,

azure-activedirectory-library-for-js

this answer as highlighted by @Christoph above should point you in the right direction.

Good Luck!

nitinr708
  • 1,393
  • 2
  • 19
  • 29