# Get user/session returns 401 error

**URL:** <https://community.dreamfactory.com/t/get-user-session-returns-401-error/3864>\
**Category:** Authentication & Security\
**Tags:** rest, authentication\
**Created:** [June 2, 2017, 12:00am UTC](https://community.dreamfactory.com/t/get-user-session-returns-401-error/3864 "2017-06-02T00:00:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kevinjanada](https://avatars.discourse-cdn.com/v4/letter/k/73ab20/32.png) [@kevinjanada](https://community.dreamfactory.com/u/kevinjanada)\
**Post date:** [June 2, 2017, 12:00am UTC](https://community.dreamfactory.com/t/get-user-session-returns-401-error/3864/1 "2017-06-02T00:00:58Z")

</div>

Hi,

I’m trying to implement a function in a mobile app that checks whether the user is signed in, by using a get request to user/session.

I can successfully send a POST request to user/session and received the user\_token.

But when i try and do a get request with the received token i get a 401 error.

This is what i did.

```
checkUserState() {
console.log(toString(this.state.token));
axios.get(url, {
  headers: {
    'Content-Type': 'application/json',
    'Accept': 'application/json',
    'X-DreamFactory-Session-Token': this.state.token,
    'X-DreamFactory-Api-Key': apiKey
  }
})
.then(response => {
  console.log(response.status);
})
.catch(error => console.log(error));
}

```

Any help would be greatly appreciated. Thanks!

---

<div class="post-metadata">

**Author:** ![kevinjanada](https://avatars.discourse-cdn.com/v4/letter/k/73ab20/32.png) [@kevinjanada](https://community.dreamfactory.com/u/kevinjanada)\
**Post date:** [June 2, 2017, 12:23am UTC](https://community.dreamfactory.com/t/get-user-session-returns-401-error/3864/2 "2017-06-02T00:23:39Z")

</div>

Never mind, i got it to work, the problem was in the order of execution of my code.  
What happened was i sent the get request before the token was set to state.
