I'm doing some code here i need to send a request from javascript client with a username and a password to a web api. In this request i need to receive a token.
This is what i have now:
var loginData = {
grant_type: 'password',
//Username and password are fill by the user in the text fields
username: username,
password: password
};
$.ajax({
type: 'POST',
crossDomain: true, //I'm having some problems with: Access-Control-Allow-Origin
crossOrigin:true,
contentType: "application/json",
url: 'https://localhost:44380/Token',
data: loginData
}).done(function (data) {
self.user(data.userName);
sessionStorage.setItem("Token", data.access_token);
}).fail("Error");
When i execute the client i receive erros related to Access-Control-Allow-Origin
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. The response had HTTP status code 400.
And Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.
Any ideas? I'm a rookie in web ...
I'm not sure if i'm doing the ajax request correctly...