Hi,
Using this tutorial: http://tylerfrankenstein.com/code/android-app-with-drupal-7-services-pho... and this: https://drupal.org/node/2013781 and this: http://www.anexusit.com/blog/drupal-7-services-3x-client-authentication-..., and adapting to my own needs, I was able to get the token, connect to the system and login whenever I click my user interface login. So far so good...
but when I try to logout, I get an error:
POST http://host/rest/user/logout.json 401 Unauthorized: CSRF validation failed 39ms
{"readyState":4,"responseText":"[\"CSRF validation failed\"]","responseJSON":["CSRF validation failed"],"status":401,"statusText":"Unauthorized: CSRF validation failed"}
sessio...7331901 (Zeile 170)
"error"
sessio...7331901 (Zeile 171)
"Unauthorized: CSRF validation failed"
This is my code:
//if logged in
try {
//Do Logout!!
//Now, proceed the logout!
$.ajax({
url: urlPath + 'backbone/rest/user/logout',
type: 'post',
//data : 'Cookie:' +userData.session_name + '=' + userData.sessid ,
dataType: 'json',
//Trying everything I can think off...
beforeSend: function (request) {
request.setRequestHeader("X-CSRF-Token", this.token);
},
error: function(XMLHttpRequest, textStatus, errorThrown){
//alert('tf_logout_button - failed to logout');
console.log(JSON.stringify(XMLHttpRequest));
console.log(JSON.stringify(textStatus));
console.log(JSON.stringify(errorThrown));
},
success: function(data){
//success code
console.log('Seams we have a success!', data);
//session ID
$.cookie(data.session_name, data.sessid);
console.log( "session name: " + data.session_name + " sessid: " + data.sessid);
//userID
$.cookie('userId', data.user.uid);
console.log('userId: ', data.user.uid);
this.userId = data.user.uid;
//populate AppSettingsModel
that.populateAppSettings(data);
}
});
}
catch (error) {
alert("tf_logout_button - " + error);
}
I can't think of more to test out... I've changed type to get, and it gives:
{"readyState":4,"responseText":"[\"Access denied for user admin\"]","responseJSON":["Access denied for user admin"],"status":401,"statusText":"Unauthorized: Access denied for user admin"}
sessio...7263504 (Zeile 172)
"error"
sessio...7263504 (Zeile 173)
"Unauthorized: Access denied for user admin"
Hope someone can shade a light on this...
Thanks in advance,
NR
Fixed
3.4
Miscellaneous
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
No activities found.