# Callback

Vendor API v0.6.6 · 2 operasjoner
Kilde: https://plasapi.com/no/vendor/v0.6.6/callback/

Gruppen brukes av operasjoner, men er ikke deklarert i spesifikasjonens tag-liste, så den har ingen beskrivelse av seg selv.

## Callback endpoint for Patron SSO login and registration.

`GET` `/callbacks/patron` · `CallbackPatron`

Callback endpoint for Patron SSO login and registration.

If the authentication is successful, the query parameters 'code' and 'state' are required. Otherwise, the query parameter 'error' is required.


### Eksempel på kall

**cURL**

```bash
curl -X GET "$PLAS_BASE_URL/callbacks/patron?version=0.6.6" \
  -H 'Accept: application/json'
```

**JavaScript**

```javascript
const response = await fetch(`${process.env.PLAS_BASE_URL}/callbacks/patron?version=0.6.6`, {
  method: "GET",
  headers: {
    "Accept": "application/json",
  },
});
```

**Python**

```python
import os
import requests

response = requests.get(
    f"{os.environ['PLAS_BASE_URL']}/callbacks/patron",
    params={
        "version": "0.6.6",
    },
    headers={
        "Accept": "application/json",
    },
)
response.raise_for_status()
```

Verten og tokenet er miljøvariabler: `PLAS_BASE_URL` providerens adresse.

### Parametere

- `code` (i `query`, `string`, valgfri) — The code obtained from the SSO patron login.
- `state` (i `query`, `string`, valgfri) — The state sent to the SSO patron login.
- `app_redirect_url` (i `query`, `string (uri)`, valgfri) — The app redirect url sent to the SSO patron login.
- `can_be_registered` (i `query`, `boolean`, valgfri) — Indicates whether the patron can be registered.
- `consent` (i `query`, `array of string`, valgfri) — Each value is formatted as `type:version` where both `type` and `version` are URL Base64 encoded (the colon separator is not encoded).
Multiple `consent` parameters may be present. Only returned when `can_be_registered` is `true`.

All consents returned to this SSO callback must be included when registering this patron through the POST /patron/registration/identifier endpoint.
If a new patron registration flow is started from this callback, any consent parameters from previous callbacks should be ignored.

- `error` (i `query`, `string enum`, valgfri) — A machine-readable error code indicating why the operation failed. Its presence signifies a failure and should be handled accordingly by the Vendor Backend.

Error codes:
- `sso_unauthorized_client` — The client is not authorized to use the SSO service.
- `sso_invalid_credentials` — The credentials provided to the SSO service are invalid.
- `sso_access_denied` — The patron's account has been blocked or is not eligible for use with this service (e.g. account locked).
- `sso_request_expired` — The SSO authentication flow expired before the patron completed it.
- `sso_login_cancelled` — The patron actively cancelled the authentication process.
- `sso_consent_denied` — The patron was authenticated but refused to give the required consent.
- `sso_session_expired` — The patron's SSO session ended or the patron was logged out during the flow.
- `sso_unknown_error` — An unspecified error occurred during the SSO authentication process.
- `provider_patron_not_found` — The patron could not be found in the provider's system.
- `provider_service_unavailable` — The provider was unable to contact the identity provider (e.g. maintenance or connectivity issues).
- `provider_unknown_error` — An unspecified error occurred in the provider's system.

For error codes such as `sso_access_denied` and `sso_consent_denied`, the vendor should advise the patron to contact their local library. Other error codes may also warrant this guidance, at the vendor's discretion.

- `error_description` (i `query`, `string`, valgfri) — A human-readable text providing additional details about the error. This is intended for logging and debugging purposes.

Felles for operasjonene: `version`. [Se den felles kontrakten på versjonssiden.](https://plasapi.com/no/vendor/v0.6.6/)

### Svar

#### `302` Redirect to the application that initialized the SSO patron login, with the code and state as query parameters.

Ikke noe innhold i svaret.

## Callback endpoint for Patron SSO delete.

`GET` `/callbacks/patron/delete` · `CallbackPatronDelete`

Callback endpoint for Patron SSO delete.

If the authentication is successful, the query parameters 'code' and 'state' are required. Otherwise, the query parameter 'error' is required.


### Eksempel på kall

**cURL**

```bash
curl -X GET "$PLAS_BASE_URL/callbacks/patron/delete?version=0.6.6" \
  -H 'Accept: application/json'
```

**JavaScript**

```javascript
const response = await fetch(`${process.env.PLAS_BASE_URL}/callbacks/patron/delete?version=0.6.6`, {
  method: "GET",
  headers: {
    "Accept": "application/json",
  },
});
```

**Python**

```python
import os
import requests

response = requests.get(
    f"{os.environ['PLAS_BASE_URL']}/callbacks/patron/delete",
    params={
        "version": "0.6.6",
    },
    headers={
        "Accept": "application/json",
    },
)
response.raise_for_status()
```

Verten og tokenet er miljøvariabler: `PLAS_BASE_URL` providerens adresse.

### Parametere

- `code` (i `query`, `string`, valgfri) — The code obtained from the SSO patron delete.
- `state` (i `query`, `string`, valgfri) — The state sent to the SSO patron delete.
- `app_redirect_url` (i `query`, `string (uri)`, valgfri) — The app redirect url sent to the SSO patron delete.
- `error` (i `query`, `string enum`, valgfri) — A machine-readable error code indicating why the operation failed. Its presence signifies a failure and should be handled accordingly by the Vendor Backend.

Error codes:
- `sso_unauthorized_client` — The client is not authorized to use the SSO service.
- `sso_invalid_credentials` — The credentials provided to the SSO service are invalid.
- `sso_access_denied` — The patron's account has been blocked or is not eligible for use with this service (e.g. account locked).
- `sso_request_expired` — The SSO authentication flow expired before the patron completed it.
- `sso_login_cancelled` — The patron actively cancelled the authentication process.
- `sso_consent_denied` — The patron was authenticated but refused to give the required consent.
- `sso_session_expired` — The patron's SSO session ended or the patron was logged out during the flow.
- `sso_unknown_error` — An unspecified error occurred during the SSO authentication process.
- `provider_patron_not_found` — The patron could not be found in the provider's system.
- `provider_service_unavailable` — The provider was unable to contact the identity provider (e.g. maintenance or connectivity issues).
- `provider_unknown_error` — An unspecified error occurred in the provider's system.

For error codes such as `sso_access_denied` and `sso_consent_denied`, the vendor should advise the patron to contact their local library. Other error codes may also warrant this guidance, at the vendor's discretion.

- `error_description` (i `query`, `string`, valgfri) — A human-readable text providing additional details about the error. This is intended for logging and debugging purposes.

Felles for operasjonene: `version`. [Se den felles kontrakten på versjonssiden.](https://plasapi.com/no/vendor/v0.6.6/)

### Svar

#### `302` Redirect to the application that initialized the SSO patron delete, with the code and state as query parameters.

Ikke noe innhold i svaret.
