Question

I am trying to get token from https://login.microsoftonline.com it gives me error But If I use https://cors-anywhere.herokuapp.com/ its works but requirement is to call this function every 2 min from more than 10 different browser so it will throw error too many request

Let me know how can we solve the issue

enter image description here

function requestToken() {
  return $.ajax({
    async: true,
    crossOrigin: true,
    url:
      'https://login.microsoftonline.com/xxxx/oauth2/v2.0/token', 
    method: 'POST',
    headers: {
      'content-type': 'application/x-www-form-urlencoded',
      'Access-Control-Allow-Origin': 'https://login.microsoftonline.com/'
    },
    data: {
      grant_type: 'client_credentials',
      'client_id ': 'xxxx', //Provide your app id
      client_secret: 'xxx', //Provide your client secret genereated from your app
      'scope ': 'https://graph.microsoft.com/.default'
    }
  });
}
Was it helpful?

Solution

https://github.com/Rob--W/cors-anywhere - Fork this repo, deploy it on heroku, then you can make like 13k requests per 5 minutes :)

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top