1

I fetch the API tokens for the current user when he signs in. This token needs to be persistent throughout the entire session.

I started by updating the default headers after the token was generated, but that update disappears when refreshing the page.

 $http.defaults.headers.common.Authorization = "Bearer #{token}"

I tried to store it using $cookieStore.put('API-TOKEN', token), but that didn't work as it was saved with the /user path. Making it only available from the /user scope.

Storing it in a Session fabricator also failed as that where emptied on every page refresh. My next attempt will be to store it using sessionStorage. Perhaps with the help from http://ngmodules.org/modules/ngStorage .

Which method is the preferred way?

Cheers, Martin

4

0 回答 0