Fluminus.Authorization (fluminus v2.2.9) View Source

Provides an abstraction over the OpenID Connect flow authorization process as used by LumiNUS

Struct fields:

  • :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 8 hours.

Creates a new Elixir.Fluminus.Authorization struct containing the given JWT and refresh token.

Obtains a Elixir.Fluminus.Authorization struct containing JWT required for authorization and cookies to refresh JWT. It will be valid for 8 hours and is non-renewable (just like fossil fuels).

Link to this section Types

Specs

t() :: %Fluminus.Authorization{jwt: String.t() | nil}

Link to this section Functions

Specs

get_jwt(t()) :: String.t() | nil

Obtains the JWT from a Elixir.Fluminus.Authorization struct. Note that the JWT is valid only for 8 hours.

Specs

new(String.t()) :: t()

Creates a new Elixir.Fluminus.Authorization struct containing the given JWT and refresh token.

Link to this function

vafs_jwt(username, password)

View Source

Specs

vafs_jwt(String.t(), String.t()) ::
  {:ok, t()} | {:error, :invalid_credentials | :no_code_in_query | any()}

Obtains a Elixir.Fluminus.Authorization struct containing JWT required for authorization and cookies to refresh JWT. It will be valid for 8 hours and is non-renewable (just like fossil fuels).

username is the username of your NUSNET account (in the format of nusstu0123456). password is the password of your NUSNET account.

Examples

iex> Fluminus.Authorization.vafs_jwt("nusstu\e0123456", "hunter2")
  {:ok,
   %Fluminus.Authorization{
     jwt: "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6ImEzck1VZ01Gdjl0UGNsTGE2eUYzekFrZnF1RSIsImtpZCI6ImEzck1VZ01Gdjl0UGNsTGE2eUYzekFrZnF1RSJ9.eyJpc3MiOiJodHRwczovL2x1bWludXMubnVzLmVkdS5zZy92Mi9hdXRoIiwiYXVkIjoidmVyc28iLCJleHAiOjE1NTIwNDQxNjcsIm5iZiI6MTU1MjA0Mzg2Nywibm9uY2UiOiJiNjE4ZjE3NzQwYTJlOWM3YjQ2ZjlmMmZmODJiYWQ1YSIsImlhdCI6MTU1MjA0Mzg2Nywi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