billstclair/elm-oauth-middleware/2.0.0

NOTE: the latest version is 3.0.0

OAuthMiddleware.EncodeDecode

JSON Encoders and Decoders for the OAuthMiddleware module.

Types

type alias Authorization =
{ name : String
, authorizationUri : String
, tokenUri : String
, apiUri : String
, clientId : String
, redirectUri : String
, scopes : Dict String String
}

Authorization information to send to the redirect (callback) server.

Usually stored in a JSON file, and read and decoded by OAuthMiddleware.getAuthorizations or OAuthMiddleware.getAuthorization.

type alias RedirectState =
{ clientId : String
, tokenUri : String
, redirectUri : String
, scope : List String
, redirectBackUri : String
, state : Maybe String
}

The state sent to the redirectUri.

This is created by OAuthMiddleware.authorize from the passed TokenAuthorization.

type alias ResponseTokenError =
{ err : String
, state : Maybe String
}

If an error occurs getting a token from the token server, it is encoded in a ResponseTokenError.

Encode/Decode state for passing over the wire.

encodeRedirectState : RedirectState -> String

Encode the redirectBackUri and user state for the authorization server.

decodeRedirectState : String -> Result String RedirectState

Decode the state encoded by encodeRedirectState.

encodeResponseToken : ResponseToken -> String

Encode the ResponseToken that is received by the redirect server from its call to OAuth.AuthorizationCode.authenticate.

decodeResponseToken : String -> Result String ResponseToken

Decode the ResponseToken that is sent back to the redirectUri from the redirect server.

encodeResponseTokenError : ResponseTokenError -> String

Encode the ResponseTokenError that may be sent back to the redirectUri from the redirect server.

decodeResponseTokenError : String -> Result String ResponseTokenError

Decode the ResponseTokenError that may be sent back to the redirectUri from the redirect server.

Encoders and Decoders

authorizationsDecoder : Decoder (List Authorization)

Decode an Authorization list.

Usually used via OAuthMiddleware.getAuthorizations.

authorizationsEncoder : List Authorization -> Value

Encode an Authorization list.

authorizationDecoder : Decoder Authorization

Decode an Authorization.

Usually used via OAuthMiddleware.getAuthorization.

authorizationEncoder : Authorization -> Value

Encode an Authorization.

redirectStateDecoder : Decoder RedirectState

Decode the state sent to the authenticate server via OAuth.AuthorizationCode.authenticate and received by the redirect server.

redirectStateEncoder : RedirectState -> Value

Encode the state sent to the authenticate server via OAuth.AuthorizationCode.authenticate and received by the redirect server.

responseTokenDecoder : Decoder ResponseToken

Decode the "response-token" query arg for the redirectBackUri.

Changes the default by swapping lenientScopeDecoder for scopeDecoder.

This isn't necessary on the client side, but is needed by the server for GitHub.

responseTokenEncoder : ResponseToken -> Value

Encode the "response-token" query arg for the redirectBackUri

responseTokenErrorDecoder : Decoder ResponseTokenError

Decode a ResponseTokenError.

responseTokenErrorEncoder : ResponseTokenError -> Value

Turn a ResponseTokenError into a Value.

nullableStringEncoder : Maybe String -> Value

Simple encoder for a nullable string.