# Dreamfactory + Angular 401 (Unauthorized)

**URL:** <https://community.dreamfactory.com/t/dreamfactory-angular-401-unauthorized/985>\
**Category:** REST API\
**Created:** [April 8, 2015, 4:56am UTC](https://community.dreamfactory.com/t/dreamfactory-angular-401-unauthorized/985 "2015-04-08T04:56:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![manol](https://avatars.discourse-cdn.com/v4/letter/m/ee7513/32.png) [@manol](https://community.dreamfactory.com/u/manol)\
**Post date:** [April 8, 2015, 4:56am UTC](https://community.dreamfactory.com/t/dreamfactory-angular-401-unauthorized/985/1 "2015-04-08T04:56:15Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![manol](https://avatars.discourse-cdn.com/v4/letter/m/ee7513/32.png) [@manol](https://community.dreamfactory.com/u/manol)\
**Post date:** [April 8, 2015, 5:17am UTC](https://community.dreamfactory.com/t/dreamfactory-angular-401-unauthorized/985/2 "2015-04-08T05:17:31Z")

</div>

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**.

---

<div class="post-metadata">

**Author:** ![jeffreystables](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/jeffreystables/32/173_2.png) [@jeffreystables](https://community.dreamfactory.com/u/jeffreystables)\
**Post date:** [April 8, 2015, 2:29pm UTC](https://community.dreamfactory.com/t/dreamfactory-angular-401-unauthorized/985/3 "2015-04-08T14:29:59Z")

</div>

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](https://github.com/dreamfactorysoftware/dsp-core/wiki/REST-API-Authentication#authentication).

---

<div class="post-metadata">

**Author:** ![manol](https://avatars.discourse-cdn.com/v4/letter/m/ee7513/32.png) [@manol](https://community.dreamfactory.com/u/manol)\
**Post date:** [April 13, 2015, 12:59pm UTC](https://community.dreamfactory.com/t/dreamfactory-angular-401-unauthorized/985/4 "2015-04-13T12:59:44Z")

</div>

Thank you jeffreystables.

I was missing the bit you pointed.
