How do I find the nc user's nc group in javascript?

I am a lightweight in this level of programming and have tried many searches on the web and this board without an answer that works (for me).
I need to modify a js script to get the current nc user’s nc group(s). the script is called from a
Util::addScript(Application::APP_ID, 'script') function in PHP. Is there any way to get the group name(s) in the javascript or pass such info to the script?

The methods I found involve getting/passing Authtokens, which I can’t also seem to find how to get.

Again, any help on such a beginner topic would be greatly appreciated!

Hello,

sorry for the late reply.

Unfortunately, I do not know of some ready to use solution in JS only. Maybe there is but I am unaware.

But, I can tell you how to do it using the backend:
You have already created an app where you can add Util::addScript(...). This app so far might have a minimal PHP implementation to serve the script at least.

You could define an (e.g. OCS) endpoint to query the groupd for a single user. You can then call this endpoint from JS and get the data.
In order to query the endpoint, you need to authenticate (as you have already mentioned). This can be done my means of using the nextcloud axios NPM package. This will do the actual token handling for you.

Cheers
Christian

Not late at all, Thank you for the reply! This is perfect; My missing link was the authentication token!

1 Like