Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Plugins

Notices

Reply
 
Thread Tools Search this Thread
Old 07-12-2026, 11:32 PM   #1
Thomasov
Junior Member
Thomasov began at the beginning.
 
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

Attached Thumbnails
Click image for larger version

Name:	Screenshot 2026-07-12 223118.png
Views:	83
Size:	22.2 KB
ID:	224383  
Attached Files
File Type: zip HardcoverToken-1.0.0.zip (2.3 KB, 2 views)
Thomasov is offline   Reply With Quote
Old Today, 12:11 AM   #2
Thomasov
Junior Member
Thomasov began at the beginning.
 
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 ''
Notes:
  • If your plugin is going to allow a token to be entered, check that first. It just makes sense semantically to consider your plugins config as an override to the shared config.
  • If you do accept a token on your own, strip the leading "Bearer " prefix; users paste the token both ways. This plugin already does that.
Thomasov is offline   Reply With Quote
Advert
Reply


Forum Jump

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


All times are GMT -4. The time now is 06:24 PM.


MobileRead.com is a privately owned, operated and funded community.