kkpoon/elm-auth0-urlparser/1.1.0

NOTE: this package is not compatible with Elm 0.19.1

Auth0.UrlParser

UrlParser for Auth0 token callback

Recommend o use this library with [kkpoon/elm-auth0](https://github.com/kkpoon/elm-auth0).

type alias Auth0CallbackInfo =
{ accessToken : String
, idToken : Maybe String
, expiresIn : Int
, tokenType : String
, state : String
}

Callback parameters from Auth0

If no openid in scope parameters in authorize request, no idToken return

type alias Auth0CallbackError =
{ error : String
, description : String
}

Callback of Error

accessTokenUrlParser : Parser (Auth0CallbackInfo -> a) a

Create a token callback UrlParser

import UrlParser exposing (..)
import Auth0.UrlParser exposing (Auth0CallbackInfo, accessTokenUrlParser)


type Route
    = AccessTokenRoute Auth0CallbackInfo
    | SomeOtherRoute


route : Parser (Route -> a) a
route =
    oneOf
        [ map AccessTokenRoute accessTokenUrlParser
        , map SomeOtherRoute (s "others")
        ]
unauthorizedUrlParser : Parser (Auth0CallbackError -> a) a

Create an error callback UrlParser

import UrlParser exposing (..)
import Auth0.UrlParser exposing (Auth0CallbackError, unauthorizedUrlParser)


type Route
    = UnauthorizedRoute Auth0CallbackError
    | SomeOtherRoute


route : Parser (Route -> a) a
route =
    oneOf
        [ map UnauthorizedRoute unauthorizedUrlParser
        , map SomeOtherRoute (s "others")
        ]