kkpoon / elm-auth0-urlparser / 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 : Maybe Basics.Int
, tokenType : Maybe String
, state : Maybe 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 : Url.Parser.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 : Url.Parser.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")
        ]