Start With Long Live Token
Getting Your Threads Token Sorted
- result
Every other node in the ComfyUI-Thread pack - PublishThread, ThreadPublishVideo, ThreadsHistory - starts by looking for a file called thread_config.json in the pack's token/ folder. If it isn't there, they all refuse with the same message: "Please execute StartWithLongLiveToken node first." This node is what creates that file. It's the one-time setup gatekeeper for the whole pack, and it's genuinely worth doing once, because it's also the fix for the most annoying part of the Threads API.
Here's the problem it solves: Meta's developer portal hands you an access token that dies after about a day. That's fine for testing, miserable for a workflow you want to run on a schedule next week. So this node exchanges your short-lived token for a long-lived one - Meta issues those for roughly 60 days - and stashes the result where every other node in the pack can read it. Run it once, forget it until the token ages out.
How it works
Under the hood it's a single request. The node calls get_long_live_access_token(), which sends a GET to https://graph.threads.net/v1.0/access_token with grant_type=th_exchange_token, your client_secret (the APP_SECRET), and the short-lived token. The API answers with a fresh token plus an expires_in value, and the node writes USER_ID, the new token, APP_SECRET, created_at, and expires_in into token/thread_config.json inside the pack's directory.
Worth knowing: the pack doesn't use the official threads_sdk at all - requirements.txt lists it, but the code talks to the Graph API directly with requests. So the token exchange is fully visible and debuggable.
The inputs
All three are plain strings, and the field names are exactly what you get from Meta Developers:
USER_ID- your Threads user IDACCESS_TOKEN- the short-lived access token (the one that expires in ~24 hours, which is the whole reason this node exists)APP_SECRET- your app secret
The only output is a result STRING: a status message. Success returns a message with your shiny new token in it; failures come back prefixed with "錯誤:" (error). Wire result into any ShowText node to actually see what happened - the node doesn't display anything on its own.
Install
Same as every node in this pack. ComfyUI Manager → search ComfyUI-Thread → install → restart. Or manually:
cd ComfyUI/custom_nodes/
git clone https://github.com/dseditor/ComfyUI-Thread
There are no model files to download, and the dependency footprint is tiny - ComfyUI already ships everything the code actually imports.
Gotchas
- Run it before anything else. Every other node hard-fails without the config file it writes.
- Treat
token/thread_config.jsonlike a key file. It's your credentials in plaintext JSON. Don't commit it, don't share it. - Tokens expire. Around the 60-day mark you'll start seeing auth errors from the other nodes - that's your cue to re-run this one. The
expires_invalue is stored right there in the JSON if you want to check. - Don't paste your short-lived token into a public workflow. It's a live credential; the README's example workflow loads one from a generated prompt, which is a bad habit for anything you plan to share.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| USER_ID | STRING | — | |
| ACCESS_TOKEN | STRING | — | |
| APP_SECRET | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| result | STRING | — |