Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for optional tokens? #4

Open
cainlevy opened this issue Feb 7, 2017 · 2 comments
Open

support for optional tokens? #4

cainlevy opened this issue Feb 7, 2017 · 2 comments

Comments

@cainlevy
Copy link

cainlevy commented Feb 7, 2017

I can't determine how to use this transport during the time period when a user has not logged in and there is no authentication token. As observed in #3, the library goes into an infinite loop when the token does not exist or an error is thrown. But even if I return an unresolved Promise to prevent the infinite loop, the transport will not send requests until the token exists.

What I would find useful is a transport that resolves an optional authentication token for each request and allowed me to manage refreshes on my own. Is there another library intended for that use case?

@cainlevy
Copy link
Author

cainlevy commented Feb 7, 2017

I briefly considered giving the transport a placeholder JWT and teaching the server to interpret it as an anonymous user, then realized that the caching logic means the placeholder token would remain for some period of time until the next refresh interval noticed the new legitimate token.

Similarly, this caching means that the transport would hold onto a token after the user had logged out. If a device switched accounts, the caching may even mean that new requests could be submitted with the old credentials.

@cainlevy
Copy link
Author

cainlevy commented Feb 9, 2017

In case anyone else happens through, here's a TypeScript implementation of a transport that simply asks for your current token every time it sends a request:

https://gist.github.com/cainlevy/5a010353847842979b0c9fd3ed38d870

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant