Support User Authentication For the Ghost Admin JavaScript SDK

I have a JavaScript SPA frontend to for ghost and I want to add the ability to preview Ghost posts by utilizing the Admin API, but I found out that user authentication mode couldn’t be used from the @tryghost/admin-api JavascriptSDK.

It would be nice to be able to utilize user-based authentication from the admin-api SDK as well as token-based authentication.

As it is I am just going to make API requests directly with Axios, which isn’t a big deal. In fact I have my SPA hosted under the same domain as the admin interface so I don’t even have to create a session cookie, because the ghost admin will do that for me. Still would be a nice feature, though.

FWIW, the Admin API already supports token auth, and should work with user auth if the user is already logged in. The only part that seems to be missing is signing in with a username and password

1 Like

That’s a good point. It probably just needs a function for creating the session.