Hello,
I'm very new in Ionic (Javascript) and I need help.
I have a PHP-Backend and I would like to use my Rest-Api to login, but I don't know how. I use this Skript: http://devdactic.com/user-auth-angularjs-ionic/
I think i must change this part in the service.js, but I don't know how.
var login = function(name, pw) {
return $q(function(resolve, reject) {
// hier wird die Übergabe aus dem Login-Formular überprüft
//if ((name == 'admin' && pw == '1') || (name == 'user' && pw == '1')) {
// // Make a request and receive your auth token from your server
// storeUserCredentials(name + '.yourServerToken');
// resolve('Login success.');
//} else {
// reject('Login Failed.');
//}
});
};
I need first a acces token:
var request = {
method: 'POST',
url: 'http://domain.com/client_crede...,
headers: {
' Authorization': 'Basic 1234567890'
}
};
var token = $http(request).then(function(response){
$access_token = response.data.access_token;
});
and with this response I need to Login
var request = {
method: 'POST',
url: 'http://domain.com/login',
headers: {
'Authorization': 'Bearer 12345678901234567890'
},
data: { "email":"info@domain.com", "password":"12345" }
};
I got always an error: Error: Unexpected request: POST
I try it for a couple days, but I think I'm to stupid. When I try it outside the script, than works (more or less - I get a feedback from my server).
Thanks for your support.
Thomas