Authenticate Users in Nextcloud from an External Website

Hey everyone!

I have an online course platform where I share videos and files with other users. Currently, I’m sharing the videos through a public link, but I want to prevent users from sharing it.

To accomplish this, I’ve been trying to set up Nextcloud to create users through my platform’s backend and then share the content with them.

Does anyone know if there’s a way to log users into Nextcloud through my backend? I want to avoid double login since users already need to be logged into my platform to access the shared links.

I think you must use OAuth2. Search the internet.

I’ve tried to make it work with OAuth2, but I couldn’t, and I also couldn’t find any examples on the internet. Everything I found related to OAuth2 and Nextcloud was about logging a user into an external website using Nextcloud as an authentication service. What I want to achieve is exactly the opposite.

Well, there is at least something in place that sounds similar: social login. This allows to create OAuth logins in general.