billstclair/elm-oauth-middleware/2.0.1

NOTE: the latest version is 3.0.0

OAuthMiddleware.ResponseToken

This module revives the ResponseToken type.

ResponseToken and its decoders were removed from truqu/elm-oauth2 version 4.0.0. This module is a copy of the version 3.0.0 code.

Most user code will never use this module, except indirectly, via OAuthMiddleware.

Types

type alias ResponseToken =
{ expiresIn : Maybe Int
, refreshToken : Maybe Token
, scope : List String
, state : Maybe String
, token : Token
}

The response obtained as a result of an authentication (implicit or not)

  • expiresIn (RECOMMENDED): The lifetime in seconds of the access token. For example, the value "3600" denotes that the access token will expire in one hour from the time the response was generated. If omitted, the authorization server SHOULD provide the expiration time via other means or document the default value.
  • refreshToken (OPTIONAL): The refresh token, which can be used to obtain new access tokens using the same authorization grant as described in Section 6.
  • scope (OPTIONAL, if identical to the scope requested; otherwise, REQUIRED): The scope of the access token as described by Section 3.3.
  • state (REQUIRED if state was present in the authentication request): The exact value received from the client
  • token (REQUIRED): The access token issued by the authorization server.

Json Decoders

responseTokenDecoder : Decoder ResponseToken

Json decoder for a response.

stateDecoder : Decoder (Maybe String)

Json decoder for a state

Constructors

makeToken : Maybe TokenType -> Maybe TokenString -> Maybe Token

Create a token from two string representing a token type and an actual token value. This is intended to be used in Json decoders or Query parsers. Returns 'Nothing' when the token type is Nothing , different from Just "Bearer" or when there's no token at all.

Same as OAuth.makeToken, but allows "bearer" as well as "Bearer" for the TokenType.

Token
-> Maybe Int
-> Maybe Token
-> List String
-> Maybe String
-> ResponseToken

Create a ResponseToken record from various parameters