truqu/elm-oauth2/3.0.0

NOTE: the latest version is 8.0.1

OAuth.AuthorizationCode

The authorization code grant type is used to obtain both access tokens and refresh tokens and is optimized for confidential clients. Since this is a redirection-based flow, the client must be capable of interacting with the resource owner's user-agent (typically a web browser) and capable of receiving incoming requests (via redirection) from the authorization server.

This is a 3-step process:

  • The client asks for an authorization to the OAuth provider: the user is redirected.
  • The provider redirects the user back and the client parses the request query parameters from the url.
  • The client authenticate itself using the authorization code found in the previous step.

After those steps, the client owns an access_token that can be used to authorize any subsequent request.

Authorize

authorize : Authorization -> Cmd msg

Redirects the resource owner (user) to the resource provider server using the specified authorization flow.

In this case, use Code as a responseType

parse : Url -> Result ParseErr ResponseCode

Parse the location looking for a parameters set by the resource provider server after redirecting the resource owner (user).

Fails with a ParseErr Empty when there's nothing

Authenticate

authenticate : Authentication -> Request ResponseToken

Authenticate the client using the authorization code obtained from the authorization.

In this case, use the AuthorizationCode constructor.

AdjustRequest ResponseToken
-> Request ResponseToken

Authenticate the client using the authorization code obtained from the authorization, passing additional custom options. Use with care.

In this case, use the AuthorizationCode constructor.