XMLHttpRequest to login.microsoftonline.com Access-Control-Allow-Origin issue
-
08-02-2021 - |
Pergunta
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
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'
}
});
}
Solução
https://github.com/Rob--W/cors-anywhere - Fork this repo, deploy it on heroku, then you can make like 13k requests per 5 minutes :)
Licenciado em: CC-BY-SA com atribuição
Não afiliado a sharepoint.stackexchange