# Angular example stores token in localstorage

**URL:** <https://devforum.okta.com/t/angular-example-stores-token-in-localstorage/5536>\
**Category:** Questions\
**Created:** [July 2, 2019, 10:58am UTC](https://devforum.okta.com/t/angular-example-stores-token-in-localstorage/5536 "2019-07-02T10:58:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![luukth](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/luukth/32/1220_2.png) [@luukth](https://devforum.okta.com/u/luukth)\
**Post date:** [July 2, 2019, 10:58am UTC](https://devforum.okta.com/t/angular-example-stores-token-in-localstorage/5536/1 "2019-07-02T10:58:45Z")

</div>

Hello,

Since yesterday I’m experimenting with okta. The angular example was a good starting point.  
[https://github.com/okta/samples-js-angular](https://github.com/okta/samples-js-angular)  
When doing research I found out that it is insecure to store tokens in localstorage. This way of storing the token is vulnerable to XSS. My question is why does this example store the token in localstorage instead of a safer method?

Some links I used for Research:  
[https://dev.to/rdegges/please-stop-using-local-storage-1i04](https://dev.to/rdegges/please-stop-using-local-storage-1i04)  
[https://www.youtube.com/watch?v=GdJ0wFi1Jyo](https://www.youtube.com/watch?v=GdJ0wFi1Jyo)  
[https://logrocket.com/blog/jwt-authentication-best-practices/](https://logrocket.com/blog/jwt-authentication-best-practices/)

---

<div class="post-metadata">

**Author:** ![andrea](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/andrea/32/2172_2.png) [@andrea](https://devforum.okta.com/u/andrea)\
**Post date:** [January 23, 2024, 7:14pm UTC](https://devforum.okta.com/t/angular-example-stores-token-in-localstorage/5536/2 "2024-01-23T19:14:51Z")

</div>

Closed on January 23, 2024, 7:14pm UTC


