# Patron Authentication

Provider API v0.6.6 · 4 operations
Source: https://plasapi.com/provider/v0.6.6/patron-authentication/

No description in the specification.

## Authenticate patron

`POST` `/patron/authentication` · `AuthenticatePatron`

Authenticate patron by credentials.

### Example request

**cURL**

```bash
curl -X POST "$PLAS_BASE_URL/patron/authentication?version=0.6.6" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer $PLAS_TOKEN" \
  -d '{
  "identifier": {
    "type": "local",
    "value": "N00012345"
  },
  "password": "correct-horse-battery"
}'
```

**JavaScript**

```javascript
const response = await fetch(`${process.env.PLAS_BASE_URL}/patron/authentication?version=0.6.6`, {
  method: "POST",
  headers: {
    "Accept": "application/json",
    "Content-Type": "application/json",
    "Authorization": `Bearer ${process.env.PLAS_TOKEN}`,
  },
  body: JSON.stringify({
    "identifier": {
      "type": "local",
      "value": "N00012345"
    },
    "password": "correct-horse-battery"
  }),
});
const data = await response.json();
```

**Python**

```python
import os
import requests

response = requests.post(
    f"{os.environ['PLAS_BASE_URL']}/patron/authentication",
    params={
        "version": "0.6.6",
    },
    headers={
        "Accept": "application/json",
        "Content-Type": "application/json",
        "Authorization": f"Bearer {os.environ['PLAS_TOKEN']}",
    },
    json={
        "identifier": {
            "type": "local",
            "value": "N00012345",
        },
        "password": "correct-horse-battery",
    },
)
data = response.json()
```

The host and token are environment variables: `PLAS_BASE_URL` the provider’s base URL · `PLAS_TOKEN` an access token.

### Parameters

Shared across operations: `version`. [See the shared contract on the version page.](https://plasapi.com/provider/v0.6.6/)

### Request body

`application/json` · required

Authentication Patron

[`PatronAuthenticationRequestBody`](https://plasapi.com/provider/v0.6.6/schemas/#PatronAuthenticationRequestBody)

### Responses

#### `200` Success

`PatronAuthenticationResponseBody`

Example (Generated from the schema):

```json
{
  "patron": {
    "address": {
      "city": "Nordby",
      "country": "Norway",
      "postalCode": "0182",
      "street": "Storgata 12"
    },
    "emails": [
      {
        "default": true,
        "email": "kari.nordmann@example.no",
        "verified": "yes"
      }
    ],
    "fullName": "Kari Nordmann",
    "givenName": "Kari",
    "identifiers": [
      {
        "type": "local",
        "value": "N00012345"
      }
    ],
    "patronId": "40218873",
    "permissions": [
      {
        "reason": "The patron has unpaid fees above the library’s limit.",
        "status": "allowed",
        "type": "off_hours"
      }
    ],
    "phoneNumbers": [
      {
        "default": true,
        "number": "+4791234567",
        "type": "mobile",
        "verified": "yes"
      }
    ],
    "pickupLocation": {
      "branchId": "nordby-main",
      "branchName": "Nordby Main Library",
      "sections": [
        {
          "id": "nordby-main-children",
          "name": "Children’s department",
          "type": "department"
        }
      ]
    },
    "reservation": {
      "postpone": {
        "fromDate": "2025-03-01",
        "toDate": "2025-03-31"
      }
    },
    "surname": "Nordmann"
  }
}
```

#### `400` The list of errors.

`Errors`

Shared response, defined once for the whole API. [See the shared contract on the version page.](https://plasapi.com/provider/v0.6.6/)

Example (Generated from the schema):

```json
{
  "errors": [
    {
      "code": 200103,
      "info": "200103: invalid/unsupported query parameter value"
    }
  ]
}
```

#### `401` Bearer token invalid, missing, or expired.

No response body.

Shared response, defined once for the whole API. [See the shared contract on the version page.](https://plasapi.com/provider/v0.6.6/)

## This will fetch a SSO URL used for patron login, matching the chosen identity provider.

`GET` `/patron/authentication/identity-provider` · `GetPatronAuthenticationUrl`

### Example request

**cURL**

```bash
curl -X GET "$PLAS_BASE_URL/patron/authentication/identity-provider?identity_provider=norway_id_portal&code_challenge=E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM&state=af0ifjsldkj&version=0.6.6" \
  -H 'Accept: application/json' \
  -H "Authorization: Bearer $PLAS_TOKEN"
```

**JavaScript**

```javascript
const response = await fetch(`${process.env.PLAS_BASE_URL}/patron/authentication/identity-provider?identity_provider=norway_id_portal&code_challenge=E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM&state=af0ifjsldkj&version=0.6.6`, {
  method: "GET",
  headers: {
    "Accept": "application/json",
    "Authorization": `Bearer ${process.env.PLAS_TOKEN}`,
  },
});
const data = await response.json();
```

**Python**

```python
import os
import requests

response = requests.get(
    f"{os.environ['PLAS_BASE_URL']}/patron/authentication/identity-provider",
    params={
        "identity_provider": "norway_id_portal",
        "code_challenge": "E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM",
        "state": "af0ifjsldkj",
        "version": "0.6.6",
    },
    headers={
        "Accept": "application/json",
        "Authorization": f"Bearer {os.environ['PLAS_TOKEN']}",
    },
)
data = response.json()
```

The host and token are environment variables: `PLAS_BASE_URL` the provider’s base URL · `PLAS_TOKEN` an access token.

### Parameters

- `identity_provider` (In `query`, [`ConfigurationPatronIdentityProviderType`](https://plasapi.com/provider/v0.6.6/schemas/#ConfigurationPatronIdentityProviderType), required) — The identity provider type, found in GET /configuration.
- `code_challenge` (In `query`, `string`, required) — A hashed value (of the code_verifier from a PKCE flow) used to secure the authorization code exchange.
- `state` (In `query`, `string`, required) — A random string to protect against CSRF and track the request state. The value should be returned to the Vendor on the callback url after login.
- `prompt` (In `query`, `string enum`, optional) — If prompt is set to login, the returned url should force a new login, even if the user is already logged in.
- `app_redirect_url` (In `query`, `string (uri)`, optional) — This value should be returned to the Vendor on the callback url after login.

Shared across operations: `version`. [See the shared contract on the version page.](https://plasapi.com/provider/v0.6.6/)

### Responses

#### `200` Success

`PatronAuthenticationIdentityProviderResponseBody`

Example (Generated from the schema):

```json
{
  "url": "https://nordby.bibliotek.example/url"
}
```

#### `400` The list of errors.

`Errors`

Shared response, defined once for the whole API. [See the shared contract on the version page.](https://plasapi.com/provider/v0.6.6/)

Example (Generated from the schema):

```json
{
  "errors": [
    {
      "code": 200103,
      "info": "200103: invalid/unsupported query parameter value"
    }
  ]
}
```

#### `401` Bearer token invalid, missing, or expired.

No response body.

Shared response, defined once for the whole API. [See the shared contract on the version page.](https://plasapi.com/provider/v0.6.6/)

## Authenticate patron by code and code verifier from SSO login.

`POST` `/patron/authentication/identity-provider` · `AuthenticatePatronByCodeAndCodeVerifier`

### Example request

**cURL**

```bash
curl -X POST "$PLAS_BASE_URL/patron/authentication/identity-provider?version=0.6.6" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -H "Authorization: Bearer $PLAS_TOKEN" \
  --data-urlencode 'code=SplxlOBeZQQYbYS6WxSbIA' \
  --data-urlencode 'code_verifier=dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk' \
  --data-urlencode 'identity_provider=norway_id_portal'
```

**JavaScript**

```javascript
const response = await fetch(`${process.env.PLAS_BASE_URL}/patron/authentication/identity-provider?version=0.6.6`, {
  method: "POST",
  headers: {
    "Accept": "application/json",
    "Content-Type": "application/x-www-form-urlencoded",
    "Authorization": `Bearer ${process.env.PLAS_TOKEN}`,
  },
  body: new URLSearchParams({
    "code": "SplxlOBeZQQYbYS6WxSbIA",
    "code_verifier": "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk",
    "identity_provider": "norway_id_portal",
  }),
});
const data = await response.json();
```

**Python**

```python
import os
import requests

response = requests.post(
    f"{os.environ['PLAS_BASE_URL']}/patron/authentication/identity-provider",
    params={
        "version": "0.6.6",
    },
    headers={
        "Accept": "application/json",
        "Content-Type": "application/x-www-form-urlencoded",
        "Authorization": f"Bearer {os.environ['PLAS_TOKEN']}",
    },
    data={
        "code": "SplxlOBeZQQYbYS6WxSbIA",
        "code_verifier": "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk",
        "identity_provider": "norway_id_portal",
    },
)
data = response.json()
```

The host and token are environment variables: `PLAS_BASE_URL` the provider’s base URL · `PLAS_TOKEN` an access token.

### Parameters

Shared across operations: `version`. [See the shared contract on the version page.](https://plasapi.com/provider/v0.6.6/)

### Request body

`application/x-www-form-urlencoded` · required

[`PatronAuthenticationByCodeAndCodeVerifierRequestBody`](https://plasapi.com/provider/v0.6.6/schemas/#PatronAuthenticationByCodeAndCodeVerifierRequestBody)

### Responses

#### `200` Success

`PatronAuthenticationByCodeAndCodeVerifierResponseBody`

Example (Generated from the schema):

```json
{
  "patron": {
    "address": {
      "city": "Nordby",
      "country": "Norway",
      "postalCode": "0182",
      "street": "Storgata 12"
    },
    "emails": [
      {
        "default": true,
        "email": "kari.nordmann@example.no",
        "verified": "yes"
      }
    ],
    "fullName": "Kari Nordmann",
    "givenName": "Kari",
    "identifiers": [
      {
        "type": "local",
        "value": "N00012345"
      }
    ],
    "patronId": "40218873",
    "permissions": [
      {
        "reason": "The patron has unpaid fees above the library’s limit.",
        "status": "allowed",
        "type": "off_hours"
      }
    ],
    "phoneNumbers": [
      {
        "default": true,
        "number": "+4791234567",
        "type": "mobile",
        "verified": "yes"
      }
    ],
    "pickupLocation": {
      "branchId": "nordby-main",
      "branchName": "Nordby Main Library",
      "sections": [
        {
          "id": "nordby-main-children",
          "name": "Children’s department",
          "type": "department"
        }
      ]
    },
    "reservation": {
      "postpone": {
        "fromDate": "2025-03-01",
        "toDate": "2025-03-31"
      }
    },
    "surname": "Nordmann"
  }
}
```

#### `400` The list of errors.

`Errors`

Shared response, defined once for the whole API. [See the shared contract on the version page.](https://plasapi.com/provider/v0.6.6/)

Example (Generated from the schema):

```json
{
  "errors": [
    {
      "code": 200103,
      "info": "200103: invalid/unsupported query parameter value"
    }
  ]
}
```

#### `401` Bearer token invalid, missing, or expired.

No response body.

Shared response, defined once for the whole API. [See the shared contract on the version page.](https://plasapi.com/provider/v0.6.6/)

## Authenticate patron without use of a password

`POST` `/patron/authentication/no-password` · `AuthenticatePatronNoPassword`

Authenticate patron without use of a password. This should only be used when absolutely necessary.

### Example request

**cURL**

```bash
curl -X POST "$PLAS_BASE_URL/patron/authentication/no-password?version=0.6.6" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer $PLAS_TOKEN" \
  -d '{
  "identifier": {
    "type": "local",
    "value": "N00012345"
  }
}'
```

**JavaScript**

```javascript
const response = await fetch(`${process.env.PLAS_BASE_URL}/patron/authentication/no-password?version=0.6.6`, {
  method: "POST",
  headers: {
    "Accept": "application/json",
    "Content-Type": "application/json",
    "Authorization": `Bearer ${process.env.PLAS_TOKEN}`,
  },
  body: JSON.stringify({
    "identifier": {
      "type": "local",
      "value": "N00012345"
    }
  }),
});
const data = await response.json();
```

**Python**

```python
import os
import requests

response = requests.post(
    f"{os.environ['PLAS_BASE_URL']}/patron/authentication/no-password",
    params={
        "version": "0.6.6",
    },
    headers={
        "Accept": "application/json",
        "Content-Type": "application/json",
        "Authorization": f"Bearer {os.environ['PLAS_TOKEN']}",
    },
    json={
        "identifier": {
            "type": "local",
            "value": "N00012345",
        },
    },
)
data = response.json()
```

The host and token are environment variables: `PLAS_BASE_URL` the provider’s base URL · `PLAS_TOKEN` an access token.

### Parameters

Shared across operations: `version`. [See the shared contract on the version page.](https://plasapi.com/provider/v0.6.6/)

### Request body

`application/json` · required

Authentication Patron without using password

[`PatronAuthenticationNoPasswordRequestBody`](https://plasapi.com/provider/v0.6.6/schemas/#PatronAuthenticationNoPasswordRequestBody)

### Responses

#### `200` Success

`PatronAuthenticationNoPasswordResponseBody`

Example (Generated from the schema):

```json
{
  "patron": {
    "address": {
      "city": "Nordby",
      "country": "Norway",
      "postalCode": "0182",
      "street": "Storgata 12"
    },
    "emails": [
      {
        "default": true,
        "email": "kari.nordmann@example.no",
        "verified": "yes"
      }
    ],
    "fullName": "Kari Nordmann",
    "givenName": "Kari",
    "identifiers": [
      {
        "type": "local",
        "value": "N00012345"
      }
    ],
    "patronId": "40218873",
    "permissions": [
      {
        "reason": "The patron has unpaid fees above the library’s limit.",
        "status": "allowed",
        "type": "off_hours"
      }
    ],
    "phoneNumbers": [
      {
        "default": true,
        "number": "+4791234567",
        "type": "mobile",
        "verified": "yes"
      }
    ],
    "pickupLocation": {
      "branchId": "nordby-main",
      "branchName": "Nordby Main Library",
      "sections": [
        {
          "id": "nordby-main-children",
          "name": "Children’s department",
          "type": "department"
        }
      ]
    },
    "reservation": {
      "postpone": {
        "fromDate": "2025-03-01",
        "toDate": "2025-03-31"
      }
    },
    "surname": "Nordmann"
  }
}
```

#### `400` The list of errors.

`Errors`

Shared response, defined once for the whole API. [See the shared contract on the version page.](https://plasapi.com/provider/v0.6.6/)

Example (Generated from the schema):

```json
{
  "errors": [
    {
      "code": 200103,
      "info": "200103: invalid/unsupported query parameter value"
    }
  ]
}
```

#### `401` Bearer token invalid, missing, or expired.

No response body.

Shared response, defined once for the whole API. [See the shared contract on the version page.](https://plasapi.com/provider/v0.6.6/)
