fluminus v1.1.1 Fluminus.Authorization View Source
Provides an abstraction over the OpenID Connect flow authorization process as used by LumiNUS
Struct fields:
:client
- theHTTPClient
containing the cookies to be used to refresh the JWT.:jwt
- the JWT Bearer token to be used by the API.
Link to this section Summary
Functions
Obtains the JWT from a Elixir.Fluminus.Authorization
struct. Note that the JWT is valid only for 30 minutes
Obtains the refresh token from a Elixir.Fluminus.Authorization
struct. Note that the refresh token is valid only for 24 hours
Obtains a Elixir.Fluminus.Authorization
struct containing JWT required for authorization and cookies to refresh JWT.
Please note that the JWT is only valid for 30 minutes, and the refresh token for 24 hours
Creates a new Elixir.Fluminus.Authorization
struct containing the given JWT and refresh token
Renews the JWT of a Elixir.Fluminus.Authorization
struct containing expired token using the cookies inside the struct.
Please note that the cookie is only valid for 24 hours
Link to this section Types
t()
View Source
t() :: %Fluminus.Authorization{
client: Fluminus.HTTPClient.t(),
jwt: String.t() | nil
}
t() :: %Fluminus.Authorization{ client: Fluminus.HTTPClient.t(), jwt: String.t() | nil }
Link to this section Functions
get_jwt(authorization)
View Source
get_jwt(Fluminus.Authorization.t()) :: String.t() | nil
get_jwt(Fluminus.Authorization.t()) :: String.t() | nil
Obtains the JWT from a Elixir.Fluminus.Authorization
struct. Note that the JWT is valid only for 30 minutes.
get_refresh_token(authorization)
View Source
get_refresh_token(Fluminus.Authorization.t()) :: String.t() | nil
get_refresh_token(Fluminus.Authorization.t()) :: String.t() | nil
Obtains the refresh token from a Elixir.Fluminus.Authorization
struct. Note that the refresh token is valid only for 24 hours.
jwt(username, password)
View Source
jwt(String.t(), String.t()) ::
{:ok, Fluminus.Authorization.t()}
| {:error, :invalid_credentials}
| {:error, any()}
jwt(String.t(), String.t()) :: {:ok, Fluminus.Authorization.t()} | {:error, :invalid_credentials} | {:error, any()}
Obtains a Elixir.Fluminus.Authorization
struct containing JWT required for authorization and cookies to refresh JWT.
Please note that the JWT is only valid for 30 minutes, and the refresh token for 24 hours.
username
is the username of your NUSNET account (in the format of e0123456).
password
is the password of your NUSNET account.
Examples
iex> Fluminus.Authorization.jwt("e0123456", "hunter2")
{:ok,
%Fluminus.Authorization{
client: %Fluminus.HTTPClient{
cookies: %{
"idsrv" => "Ksxzb3TnGZaxhpzK-Bi9AgkrCxcFNX76bL_IysaLMdOxqSA-FmnT3oEwXeiuOIIkt2buDXcmbhDgGJmfyOoQpUth01_hK0tEdd9ve37VzBQRP32HIVCiE_s7M-vGgTAnxV08NjcQ27CoNeFhD2gZmoU50ncxQFAOtys2x0jD3j80srBITiKU1jJ59RA8Y2UyRqAOgzkk95CvPDpcTsP3g925qJ9JKG0tCZ7TxJ9D0PSeQ-lHfPW8mD_6qzztwr0StiEPaVr-iFzniuixFY82_moVDbzfoSOl2SVNkZlY2d-mY3o6Yt6HH6Jr_uslQXMtsa-1UEQFAP0GAE9RpARSrtA3hx_gsYnujHyIAKrlKTevA7xAAEw97U7Hxs2BAQzVx2P-AGhz-MZ_0AsfwQNC0_4zfw2OVQsYlyLrZoyyoK0"
}
},
jwt: "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6ImEzck1VZ01Gdjl0UGNsTGE2eUYzekFrZnF1RSIsImtpZCI6ImEzck1VZ01Gdjl0UGNsTGE2eUYzekFrZnF1RSJ9.eyJpc3MiOiJodHRwczovL2x1bWludXMubnVzLmVkdS5zZy92Mi9hdXRoIiwiYXVkIjoidmVyc28iLCJleHAiOjE1NTIwNDQxNjcsIm5iZiI6MTU1MjA0Mzg2Nywibm9uY2UiOiJiNjE4ZjE3NzQwYTJlOWM3YjQ2ZjlmMmZmODJiYWQ1YSIsImlhdCI6MTU1MjA0Mzg2NywiYXRfaGFzaCIaIlA5TTF4dU9fNVVrdklXNDdKUHhYYn9iLCJjX2hhc2giOiJzTVZMRVM42Us0VjFIaFlPZmUtenRnIiwic2lkIjoiOTVlNTJjZjI4OTMyNzMyZjRjZjIxMzAxZjQ3NTE3ODQiLCJzdWIiOiIwMzA4OTI1Mi0wYzk2LTRmYWItYjA4MC1mMmFlYjA3ZWVi2GYiLCJhdXRoX3RpbWUiOjE1NTIwNDM4NjcsImlkcCI6Ikakc3J2IiwiYWRkcmVzayI6IlJlcXVlc3QgYWxsIGNsYWltcyIsImFtciI6WyJwYXNzd29yZCJdfQ.ElRgTpfGJc3np4N37JZZFr_8ZXkuBYjw_vxFxt_GV311gGJlDnh9YDepzWnIsNgtgnuLlkHdb73q9mt2XIcn6YHL0r2kI-CbdKx57aaDfE3-tudRgEv8vXIh53q0Tt61OR5_86qB2qr3QQn0WFvC5VJMYfQ-MJevGrcKFe80vFQPihSHtpznD3G7SyczY3m1yRWsiHNgymvUc4LM5QETOHYv72jDfo7VcxFpscwr4o3os_9fYM_62WuRo7OOL3WdD2XAQB6NGaeakIOQwqMbDSMSvpc0McpGW4uljlmBTiRfzCn7i9bnbfkWLJ5C6mK2o2CWgp1rr2f-HZsIIe-w2Q"
}}
new(jwt, refresh_token)
View Source
new(String.t(), String.t()) :: Fluminus.Authorization.t()
new(String.t(), String.t()) :: Fluminus.Authorization.t()
Creates a new Elixir.Fluminus.Authorization
struct containing the given JWT and refresh token.
renew_jwt(auth)
View Source
renew_jwt(Fluminus.Authorization.t()) ::
{:ok, Fluminus.Authorization.t()}
| {:error, :invalid_authorization}
| {:error, any()}
renew_jwt(Fluminus.Authorization.t()) :: {:ok, Fluminus.Authorization.t()} | {:error, :invalid_authorization} | {:error, any()}
Renews the JWT of a Elixir.Fluminus.Authorization
struct containing expired token using the cookies inside the struct.
Please note that the cookie is only valid for 24 hours.
Examples
iex> Fluminus.Authorization.renew_jwt(auth)
{:ok, }