Create Users and assign Channels using the Admin API

I need to be able to create users and manage their Channels via my Applications Admin API.

I have already create my Admin Credentials but I cannot grok how to use this to connect to the Admin API, I feel like I am missing something in the documentation that should be fairly simple.

Anyone have any guidance as how to connect to the Admin API and create a User?

It’s expected that your backend service/API has network access to Sync Gateway’s Admin API port (4985), and can use the set of admin credentials you created to manage users via the Admin HTTP REST API:

Hi,
I have read over that several times, it is not clear, or at least not clear to me.

I have my credentials, but what endpoint to do I call to authenticate?

Is it basic auth?

What is the response?

Do I get a token I then use for all of my subsequent requests?

I apologize, the documentation is not clear, or clear to me at least.

Ah ok! Yes you’ll need to authenticate each request with HTTP basic auth headers

We don’t have anything like session cookies for the admin API - only the public API supports cookies/OIDC/etc.

Thank you, so I was heading in the right direction - I got it sorted out:

I was working off this documentation for authentication:
https://docs.couchbase.com/sync-gateway/current/rest_api_admin.html#tag/Authentication/operation/get_db-_oidc

And here for users:
https://docs.couchbase.com/sync-gateway/current/rest_api_admin.html#tag/Database-Security/operation/get_db-_user-

It was not clear in the docs, or I missed it, that you need to use Basic Auth for all requests and so I assumed I needed to call an Auth Endpoint and get some token back to use for subsequent requests.

Basic Auth makes it nice and simple, thanks for the help!

1 Like