Dreamfactory + Angular 401 (Unauthorized)

Hello.

I’m trying to use the angular SDK but always get a 401 (Unauthorized).

Already set config:

.constant('DSP_URL', 'http://myaddress.com')
.constant('DSP_API_KEY', 'myapp')
.config(['$httpProvider', 'DSP_API_KEY', function($httpProvider, DSP_API_KEY) {
$httpProvider.defaults.headers.common['X-DreamFactory-Application-Name'] =  DSP_API_KEY;
}])

then I can login:

	$scope.$on('api:ready', function(event) {
	console.debug('ready');
	DreamFactory.api.user.login($scope.creds, .....
});

and I get a successful response, so I’m logged in.

On the following code is where a get a 401 error

DreamFactory.api.feng.getRecords({"table_name":"fo_project_tasks"}).then(.....

I’ve created the service, created roles (even no need for it, because a login as an admin), allowed * in CORS, but still no luck.

Any advice will be welcome.

Best regards.

I read in another post that if I enable Guest Users and choose a service then I can access data from that service, it works, but of course that’s not the way.

Are you passing the X-DreamFactory-Session-Token header with the received session_id on each subsequent call after logging in? Please refer to this page from the documentation.

1 Like

Thank you jeffreystables.

I was missing the bit you pointed.