Reputation: 151
One of the use cases of doing Implicit Grants for OAuth 2 is for web apps that use javascript. My question is how do you store the access token?
For web apps with server side scripting I normally store the access token in a database or in a cookie that's not JS accessible. For a mobile app which also uses implicit grant, you can store the token in the device. But for a JS web app, the only way I could think of is to store it in memory in a private variable. The difference with having server side scripting is with this is that once the page is closed, you're technically logged out. But how is this normally done?
Upvotes: 0
Views: 1516
Reputation: 2424
You can store in the HTML5 Web Storage
$window.sessionStorage.token = 'serverToken';
The data persisted there lives until the browser tab is closed.
You also can store in a cookie, you can read more about that here: https://stormpath.com/blog/where-to-store-your-jwts-cookies-vs-html5-web-storage/
Upvotes: 1