Headless Sync: how to get OBSIDIAN_AUTH_TOKEN variable?

I am trying to set up headlessly-synced vault on my VPS via docker-compose, using node:bookworm as a base image.

One thing I do not quite understand is OBSIDIAN_AUTH_TOKEN variable ( Obsidian Headless - Obsidian Help ). How does one get it? I could not find any reference in docs and in Obsidian UI.

I’ve tried setting it to a random string and it did not seem to work.

I have also tried to authenticate via “ob login” and even though id does say “logged in as (my email) ”, when I run plain “ob login” again immediately after that, it says “not logged in”.

What am I missing? Maybe I’m using the wrong base image? Perhaps docs should be a bit more concrete on that matter?

2 Likes

To my understanding there is not a easy/supported way to get the token without an interactive environment where you need to ob login first. Even then, the token is stored on the user’s keychain.

Here’s what I did:

  1. ob login through the normal flow with my email, password, mfa
  2. I used find ~ -path "*obsidian-headless*" 2>/dev/nullto search for the token.
  3. The token was in /home/[my username]/.config/obsidian-headless/auth_token
  4. Use that token in your docker-compose or export it as an environment variable etc…

Note: if you ever ob logout it will delete that auth token and invalidate it.

Hope this helps!

1 Like

for me it was at $HOME/.obsidian-headless/auth_token after ob login

1 Like

The way obsidian headless works has changed, please update and read the docs again. Expect more breaking changes in this beta period.

https://www.npmjs.com/package/obsidian-headless

1 Like