Skip to content

Instantly share code, notes, and snippets.

@grrinchas
Created December 30, 2017 11:11
Show Gist options
  • Save grrinchas/dcb348c8594a6ce13e022bb08494d2ee to your computer and use it in GitHub Desktop.
Save grrinchas/dcb348c8594a6ce13e022bb08494d2ee to your computer and use it in GitHub Desktop.
parseToken : Parser (Maybe Token -> a) a
parseToken =
custom "ACCESS_TOKEN" <|
\segment ->
case String.split "&" segment |> List.map (String.split "=") of
[ [ "access_token", accessToken ]
, [ "expires_in", expires ]
, [ "token_type", type_ ]
, [ "state", state ]
, [ "id_token", idToken ] ] ->
case String.toInt expires of
Ok int ->
Ok <| Just <| Auth0Token accessToken idToken type_ int
Err e ->
Err "Missing expires_in"
_ ->
Err "Not an access token"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment