Inject cookies and handle redirects when rendering markdown

What I’m trying to do

For my use case, I need to embed link to an image, something like ![]( … This works fine however, my image server is protected by checking for an Auth cookie. I have the auth cookie and can successfully make calls to the server from a plugin, or the command line.

The flow looks something like:

  • call to image server → get a 307 to auth server
  • call auth server with auth token in a cookie → get a 307 to image server with a sso_token in the url
  • call the image serve → get a 307 to the orginal link with the sso_token in the cookie
  • call image server with a the sso_cookie → 200 OK / Image content.

Things I have tried

I’ve written a plugin that handles the redirects and the cookies correctly.

I’ve tried injecting the cookie in the electron default session, but no luck.

I’ve also tried pulling the image in “manually” and rendering it as a “data:” URL but that’s completely unwieldly.

I tried registering a custom obsidian:// url hander to intercept the call, but that gives an net::ERR_UNKNOWN_URL_SCHEME error if I do something like ![](obsidian://auth?url=the_url)

Do you know if I can either intercept the request to inject the cookie, or inject the cookie into the session that is being used to make the call to fetch the image?

I am ok if this needs to happen through a plugin.

Thanks for your help!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.