I’m wanting to use some of ionic.io services. Analytics appears to be working ok but I’m not able to create (save) an Ionic user from my app. I keep getting a 403 error back and the response says CSRF Failed: CSRF token missing or incorrect. I’ve mostly been working in Chrome with CORS disabled. Same thing happens when I run from the iOS sim as well. Any help or suggestions are greatly appreciated.
PUT https://apps.ionic.io/api/v1/app/<my _app_id>/users/1 403 (FORBIDDEN)
Ionic User: Error: Request Failed with status code of 403(…)
Here’s the block of code I’m trying to run. Note that the user and ionicUser already exist in the scope.
ionicUser = Ionic.User.current();
if (!ionicUser.id) {
ionicUser.id = user.id.toString();
}
ionicUser.set('firstName', user.firstName);
ionicUser.set('lastName', user.lastName);
ionicUser.set('email', user.email);
ionicUser.save().then(function(response){
$logger.debug('UserService.createIonicUser > ionic user ' + ionicUser.id + ' saved');
}, function(error){
$logger.error('UserService.createIonicUser > error saving ionic user: ' + error);
});
Here’s my ionic info:
Cordova CLI: 5.4.1
Gulp version: CLI version 3.9.0
Gulp local: Local version 3.9.0
Ionic Version: 1.2.4
Ionic CLI Version: 1.7.14
Ionic App Lib Version: 0.7.0
ios-deploy version: 1.8.4
ios-sim version: 5.0.6
OS: Mac OS X El Capitan
Node Version: v4.2.4
Xcode version: Xcode 7.2 Build version 7C68