I’d like this to be discussion of different approaches to keeping JWTs fresh, so authenticated requests aren’t failing due to expired tokens.
I am hoping to find some examples of nice patterns that I can adopt for my own Elm applications, as I’ve already tried a few, but haven’t come up with a “clearly best” approach to this.
An example to explain from
Assume you’re using a web-app where the JWT is expired, but can be refreshed:
type JWT = JWT refreshToken : JWT -> Cmd JWT refreshTokenAsTask : JWT -> Task Never JWT
Your application is initializing, getting new articles from 2 sources concurrently. This happens not only on initialization, but also every once in a while, depening on user-input:
type Article = Article type ExpiredJWT = ExpiredJWT getNYTArticles : (Result ExpiredJWT (List Article) -> msg) -> JWT -> Cmd msg getNYTArticlesAsTask : JWT -> Task ExpiredJWT ((List Article)) getWPArticles : (Result ExpiredJWT (List Article) -> msg) -> JWT -> Cmd msg getWPArticlesAsTask : JWT -> Task ExpiredJWT ((List Article))
Since your JWT is expired, what logic would you apply to get the two lists of articles?