We are in the process of migrating this forum. A new space will be available soon. We are sorry for the inconvenience.

No 'Access-Control-Allow-Origin' header is present on the requested resource.


bob-leponge
10-08-2014, 12:28 PM
Bonjour,

Je souhaite utiliser l'API Hubic, mais je me retrouve confronté à une erreur lors de la demande d'"access token".
L'ereur est la suivante :
"XMLHttpRequest cannot load https://api.hubic.com/oauth/token/. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access."

Comment résoudre cette erreur ?

Voici l'appel en POST que je réalise :

$.ajax({
type: 'POST',
url: 'https://api.hubic.com/oauth/token/',
crossDomain : true,
data: {code: getParameter('code'),redirect_uri: 'http%3A%2F%2Flocalhost%2Fcloudtest%2Fpage2.html', grant_type: 'authorization_code'},
beforeSend: function (xhr) {
xhr.setRequestHeader ("Authorization", "Basic YXBpX2h1YmljXzFrOTBqdUpBZFQ2VXZ4aTZsUXl6SzRHaWxsSD c1VVRhOnRZWE9GaWpYb1dPR2hGcTE1MTZ6RHd1RzVnR0ZiTnZJ bGRhSFdsdmM2MnZOSjhmalVWU25Ed3BWemtyU3VwcXg=");
},
success:function(data) {
alert(data);
}
});

Merci d'avance pour vos réponses.