|
|
#1 |
|
Junior Member
![]() Posts: 3
Karma: 10
Join Date: Jul 2026
Device: iPhone
|
[Config] Hardcover Token
Hardcover Token
I was exploring the Hardcover.app API and I found myself setting up a few plugins and repeating the same token logic in all of them. I thought it might be nice to set up a config plugin that exists just to store the hardcover token so other plugins could just reference that and save themselves the effort. I set up my plugins to optionally allow an override within their own config but there's no reason that has to be mandatory. I will upload those other plugins soon. Here is the Github repo https://github.com/Thomasov/hardcover-token |
|
|
|
|
|
#2 |
|
Junior Member
![]() Posts: 3
Karma: 10
Join Date: Jul 2026
Device: iPhone
|
I thought I would add some instructions in case there was another dev who wanted to use some of the conventions this plugin is establishing
You can use the shared token without depending on this plugin in any way. The token lives at plugins/hardcover_shared.json in calibre's configuration directory, just a JSONConfig file with a single api_token key. Just read that path, so your plugin keeps working whether or not Hardcover Token is installed. The recommended pattern is Code:
from calibre.utils.config import JSONConfig
def hardcover_token(own_token=''):
# 1. the plugin's own configured token wins (deliberate local override)
# 2. otherwise the shared token stored by the Hardcover Token plugin
candidates = [own_token]
try:
candidates.append(
JSONConfig('plugins/hardcover_shared').get('api_token', ''))
except Exception:
pass
for token in candidates:
token = (token or '').strip()
if token.lower().startswith('bearer'):
token = token[6:].strip()
if token:
return token
return ''
|
|
|
|
| Advert | |
|
|
![]() |
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Dropbox module fail - DB keeps changing token! | LivresInOz | KOReader | 4 | 10-21-2022 02:49 AM |
| A token for current path | mrmikel | Editor | 8 | 10-03-2014 07:55 AM |
| PRS-600 Gift token request | greylin | Sony Reader | 0 | 02-04-2011 06:34 PM |