This is my first post and I hope I categorized this into the correct section. I am very interested in DreamFactory for AngularJS and using it in my PhoneGap application. However, I am stuck on the registration procedure.
Unless you’ve enabled Guest User access in the Config tab (which allows users assigned to a guest role to make API calls without authenticating), you need to first authenticate and get a session token. This session token must be passed on subsequent API calls.
Thank you for the quick response! I see that register just returns success, so afterwards I made a subsequent request to login the user as you suggested. Now I am on on a slightly different issue. Sorry for all the questions!
I am trying to make authenticated calls to the database using the example below:
var record = {
table_name: 'exampleTable',
session_id: UserService.getUser().sessionId,
};
DreamFactory.api.db.getRecord(record,
function(result) {
console.log(result);
},
function(error) {
console.log(error);
});
I already feel like I am passing the session_id incorrectly. I took a look at the in-depth authentication tutorial and it is very impressive. But a little too much of what I am looking for. The angular-dreamfactory module is just perfect for what I am trying to do.
When I run the above code I get:
TypeError: Cannot read property 'getRecord' of undefined
It is in fact defined as I dumped it into the console, console.log(DreamFactory);, and saw it in the object. It’s there, I just must not be using it right.
EDIT:
After scouring the web I landed on a pretty blatant fact - the API did not build yet! Makes sense haha. So I wrapped the call in:
$scope.$on('api:ready', function(event) { });
But now I am left with an unauthorized error with no valid session id. So, I must be passing this incorrectly.