diff --git a/docs/env-variables.md b/docs/env-variables.md index 060444fc..4d14a117 100644 --- a/docs/env-variables.md +++ b/docs/env-variables.md @@ -15,7 +15,7 @@ This page outlines the environment variables used in the YamTrack project. | `IGDB_ID` | IGDB API key for games. A default key is provided, but it's recommended to get your own as it has a low rate limit. | | `IGDB_SECRET` | IGDB API secret for games. A default value is provided, but it's recommended to get your own as it has a low rate limit. | | `IGDB_NSFW` | Default to `False`. Set to `True` to include adult content in game searches. | -| `HARDCOVER_API` | Hardcover API key for books. A default key is provided, but it's recommended to get your own as it has a low rate limit. | +| `HARDCOVER_API` | Hardcover API key for books. A default key is provided, but it's recommended to get your own as it has a low rate limit. Custom values must include the `Bearer ` prefix. | | `COMICVINE_API` | ComicVine API key for comics. A default key is provided, but it's recommended to get your own as it has a low rate limit. | ## Media Import diff --git a/src/config/settings.py b/src/config/settings.py index 75eab9f6..389132a4 100644 --- a/src/config/settings.py +++ b/src/config/settings.py @@ -18,6 +18,7 @@ from decouple import ( undefined, ) from django.core.cache import CacheKeyWarning +from django.core.exceptions import ImproperlyConfigured BASE_URL = config("BASE_URL", default=None) if BASE_URL: @@ -424,6 +425,10 @@ HARDCOVER_API = config( "j4MVAEi_-w2N7DuiMgAxkfVc6RuKd88AHrOyzF5xLyU", ), ) +HARDCOVER_API = HARDCOVER_API.strip() +if not HARDCOVER_API.startswith("Bearer "): + msg = "HARDCOVER_API must start with 'Bearer '." + raise ImproperlyConfigured(msg) COMICVINE_API = config( "COMICVINE_API",