This is an alternative site for discovering Elm packages. You may be looking for the official Elm package site instead.
Supports decoding Jwt tokens & making authenticated HTTP requests
version 5.3.0
license BSD3
native-modules False
elm-version 0.18.0 <= v < 0.19.0
Tag 7.0.0
Committed At 2018-12-28 11:02:30 UTC
elm-lang/http 1.0.0 <= v < 2.0.0 1.0.0
elm-lang/core 5.0.0 <= v < 6.0.0 5.1.1



Elm helpers for working with Jwt tokens.

A collection of functions to decode Jwt tokens, and to use them for authenticated CRUD requests.

Decode a token

A Jwt is a Base64 string that has three parts

  • header
  • content
  • signature

The library functions decodeToken and tokenDecoder provide the means to decode the content of a token, while checkTokenExpiry and isExpired specifically analyse whether the token remains within its expiry time.

Make an authenticated CRUD request

The library also provides modified versions of thet standard Http functions to make CRUD requests with the Authorization header set to "bearer "

    url =
    body =
        Http.jsonBody <some Value>
in token { url = url, body = body, expect = Http.expectJson OnData (Json.Decode.field "confirmation" Json.Decode.string) }


An example of the software working with a Node backend is provided.

A blog about using the library with Phoenix can be found here.


  • 7.0.0: (0.19) Http 2.0.0 necessitated major changes. I took the opportunity to simplify my code and the JwtError type in particular. All token processing functions now also do a cursory check that the header is valid json
  • 6.0.0: (0.19) Update
  • 5.3.0: Adds decoder got Elixir-Guardian token
  • 5.2.0: Update NodeJS example
  • 5.1.0: Adds a decoder for the Firebase Jwt.
  • 5.0.0 (0.18): Corrects a typo in name of checkTokenExpiry and separates out createRequestObject
  • 4.0.0 (0.18): Elm's Http library has undergone a major rewrite for 0.18 and this library depends upon it. As a result much has changed and you are encouraged to re-look at the examples and the docs.
  • 3.0.0 (0.18): Elm 0.17 users should use version 2.0.0.
  • 2.0.0 (0.17): The one breaking change is that authenticate now returns Task JwtError String rather than Task never (Result JwtError String). It is better to leave it to the user to handle the conversion to a Cmd. Elm 0.16 users should use version 1.0.2.