foliolib.folio.api.authtoken.Token

class foliolib.folio.api.authtoken.Token(tenant: str)

Bases: foliolib.folio.FolioApi

mod-authtoken API

Base class of the Folio API

Parameters

tenant (str) – Tenant id

Methods

token_invalidate(refreshToken)

Invalidate a single token

token_invalidate_all()

Invalidate all tokens for a user

token_legacy(signTokenPayload)

Deprecated.

token_refresh(refreshToken)

Returns a new refresh token and a new access token.

token_sign(signTokenPayload)

Returns a signed, expiring access token and refresh token.

token_sign_legacy(signRefreshToken)

Returns a signed, expiring refresh token.

token_invalidate(refreshToken)

Invalidate a single token

POST /token/invalidate

Parameters

refreshToken (dict) – See Schema below.

Raises
  • OkapiRequestError – Bad request

  • OkapiRequestFatalError – Internal error

Schema

{
    "description": "The refresh token being presented to get a new refresh token and access token",
    "type": "object",
    "properties": {
        "refreshToken": {
            "type": "string",
            "description": "The JWE refresh token"
        }
    },
    "required": [
        "refreshToken"
    ],
    "additionalProperties": false
}
token_invalidate_all()

Invalidate all tokens for a user

POST /token/invalidate-all

Raises
  • OkapiRequestError – Bad request

  • OkapiRequestFatalError – Internal error

token_legacy(signTokenPayload)

Deprecated. Will be removed in a future release. Please use /token/sign instead. Returns a signed, non-expiring legacy access token.

POST /token

Parameters

signTokenPayload (dict) – See Schema below.

Returns

See Schema below.

Return type

dict

Raises
  • OkapiRequestError – Bad request

  • OkapiRequestFatalError – Internal error

Schema

{
    "description": "The POST body for the request to generate a signed token",
    "type": "object",
    "properties": {
        "payload": {
            "type": "object",
            "description": "The payload of the token signing request",
            "properties": {
                "sub": {
                    "type": "string",
                    "description": "The subject (the username) for the user"
                }
            },
            "required": [
                "sub"
            ],
            "additionalProperties": true
        }
    },
    "required": [
        "payload"
    ],
    "additionalProperties": false
}
{
    "description": "The signed JWT token based on the payload",
    "type": "object",
    "properties": {
        "token": {
            "type": "string",
            "description": "The JWT token"
        }
    },
    "required": [
        "token"
    ],
    "additionalProperties": false
}
token_refresh(refreshToken)

Returns a new refresh token and a new access token. Also returns the expiration of each token in the body of the response. Time to live is 10 minutes for the access token and one week for the refresh token.

POST /token/refresh

Args:

refreshToken (dict): See Schema below.

Returns:

dict: See Schema below.

Raises:

OkapiRequestError: Bad request OkapiRequestFatalError: Internal error

Schema:

{
    "description": "The refresh token being presented to get a new refresh token and access token",
    "type": "object",
    "properties": {
        "refreshToken": {
            "type": "string",
            "description": "The JWE refresh token"
        }
    },
    "required": [
        "refreshToken"
    ],
    "additionalProperties": false
}
{
    "description": "A signed JWT token when used in the context of a dummy token. Otherwise, a signed JWT access token and a signed JWE refresh token.",
    "type": "object",
    "properties": {
        "token": {
            "type": "string",
            "description": "A dummy token"
        },
        "refreshToken": {
            "type": "string",
            "description": "A refresh token"
        },
        "accessToken": {
            "type": "string",
            "description": "An access token"
        }
    },
    "additionalProperties": false
}
token_sign(signTokenPayload)

Returns a signed, expiring access token and refresh token. Also returns the expiration of each token in the body of the response. The access token time to live is 10 minutes and the refresh token is one week.

POST /token/sign

Args:

signTokenPayload (dict): See Schema below.

Returns:

dict: See Schema below.

Raises:

OkapiRequestError: Bad request OkapiRequestFatalError: Internal error

Schema:

{
    "description": "The POST body for the request to generate a signed token",
    "type": "object",
    "properties": {
        "payload": {
            "type": "object",
            "description": "The payload of the token signing request",
            "properties": {
                "sub": {
                    "type": "string",
                    "description": "The subject (the username) for the user"
                }
            },
            "required": [
                "sub"
            ],
            "additionalProperties": true
        }
    },
    "required": [
        "payload"
    ],
    "additionalProperties": false
}
{
    "description": "A signed JWT token when used in the context of a dummy token. Otherwise, a signed JWT access token and a signed JWE refresh token.",
    "type": "object",
    "properties": {
        "token": {
            "type": "string",
            "description": "A dummy token"
        },
        "refreshToken": {
            "type": "string",
            "description": "A refresh token"
        },
        "accessToken": {
            "type": "string",
            "description": "An access token"
        }
    },
    "additionalProperties": false
}
token_sign_legacy(signRefreshToken)

Returns a signed, expiring refresh token. This is a legacy endpoint and should not be called by new code and will soon be fully depreciated.

POST /refreshtoken

Args:

signRefreshToken (dict): See Schema below.

Returns:

dict: See Schema below.

Raises:

OkapiRequestError: Bad request OkapiRequestFatalError: Internal error

Schema:

{
    "description": "The request to sign a new refresh token",
    "type": "object",
    "properties": {
        "userId": {
            "type": "string",
            "description": "The user id of the request",
            "format": "uuid"
        },
        "sub": {
            "type": "string",
            "description": "The subject (user id) of the request"
        }
    },
    "required": [
        "userId",
        "sub"
    ],
    "additionalProperties": false
}
{
    "description": "The signed JWT token based on the payload",
    "type": "object",
    "properties": {
        "token": {
            "type": "string",
            "description": "The JWT token"
        }
    },
    "required": [
        "token"
    ],
    "additionalProperties": false
}