How Can I Secure Authentication Tokens Long-Term Without a Backend?

0
15
Asked By CuriousTraveler84 On

I'm creating a simple website that interacts with a third-party API requiring user authentication. I've set it up with PKCE and am receiving both an access token and a refresh token. However, I want to keep this authentication live so users won't need to log in repeatedly. From my research, it appears that the only way to securely maintain these tokens is by sending them to a backend and using HttpOnly cookies. Is that the case? I want to be sure because this would be my only reason to create a backend API, which would add extra costs to my project.

4 Answers

Answered By FrontendFreak99 On

Just a heads up, if you're using Dropbox's API, your users should log in on their website and authorize your app before returning to yours. Make sure you're not handling their credentials directly.

Answered By DevNinja42 On

Actually, you only need a backend if you plan to refresh tokens before they expire, and if the third-party API can't handle that. If security is a major concern, definitely consider encrypting sensitive tokens.

Answered By CodeWizard77 On

It seems you can’t fully secure your tokens without a backend API. If you keep refresh tokens in localStorage, they’re at risk from XSS attacks. It’s risky to use them in the frontend without a secure approach.

Answered By TechGuru23 On

Yes, to ensure long-term security for your tokens, you really do need a backend. Storing them in localStorage opens up vulnerabilities where an injected script or an XSS error could easily access those tokens.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.