# Callback

Vendor API v0.6.7 · 2 operations
Source: https://plasapi.com/vendor/v0.6.7/callback/

Where the provider sends a patron's browser back after an identity provider flow for login, registration or deletion. The callback carries what the vendor needs to finish the flow with the provider, or says that the flow did not complete and why.

## 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.


### Example request

**cURL**

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

**JavaScript**

```javascript
const response = await fetch(`${process.env.PLAS_BASE_URL}/callbacks/patron?version=0.6.7`, {
  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.7",
    },
    headers={
        "Accept": "application/json",
    },
)
response.raise_for_status()
```

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

### Parameters

- `code` (In `query`, `string`, optional) — The code obtained from the SSO patron login.
- `state` (In `query`, `string`, optional) — The state sent to the SSO patron login.
- `app_redirect_url` (In `query`, `string (uri)`, optional) — The app redirect url sent to the SSO patron login.
- `can_be_registered` (In `query`, `boolean`, optional) — Indicates whether the patron can be registered.
- `consent` (In `query`, `array of string`, optional) — 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` (In `query`, `string enum`, optional) — 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` (In `query`, `string`, optional) — A human-readable text providing additional details about the error. This is intended for logging and debugging purposes.

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

### Responses

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

No response body.

## 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.


### Example request

**cURL**

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

**JavaScript**

```javascript
const response = await fetch(`${process.env.PLAS_BASE_URL}/callbacks/patron/delete?version=0.6.7`, {
  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.7",
    },
    headers={
        "Accept": "application/json",
    },
)
response.raise_for_status()
```

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

### Parameters

- `code` (In `query`, `string`, optional) — The code obtained from the SSO patron delete.
- `state` (In `query`, `string`, optional) — The state sent to the SSO patron delete.
- `app_redirect_url` (In `query`, `string (uri)`, optional) — The app redirect url sent to the SSO patron delete.
- `error` (In `query`, `string enum`, optional) — 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` (In `query`, `string`, optional) — A human-readable text providing additional details about the error. This is intended for logging and debugging purposes.

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

### Responses

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

No response body.
