I would like to develop an application (NodeJS, vueJS, postgreSQL) that uses the nextcloud user accounts. The idea is that the user authenticates with his nextcloud ID, and can then access both nextcloud and my website. Note that my application is not a nextcloud module or nextcloud application. It’s a full web site, but I would like to base it on nextcloud to identify the user
I did some research on the web, but I did not find a simple explanation of how to do it … is it possible?
Olivier
There are a few different approaches that you can take in order to authenticate users of an external app via an account in your nextcloud instance. These include:
Using OAuth 2.0 would allow your website to authenticate users externally via your nextcloud instance.
Here is how that would work in your case:
nextcloud-instance-address/index.php/apps/oauth2/authorize) while identifying itself using a Client Identifieryour-instance-address/index.php/apps/oauth2/api/v1/token) with Client secret key. Your website acquires access token as a response.nextcloud-instance-address/index.php/ocs/v2.php/cloud/user?format=jsonIt's a good idea to store the access token in a cookie-based session.
Setup is quite simple (at least on the side of your nextcloud instance) - you have to add your website in Administrator Security Settings section of nextcloud's admin account. You will have to specify the Redirection URI which your website will use to retrieve the request token upon successful login. The Client secret key and Client Identifier will both be generated for you in nextcloud's admin panel.
This tutorial will help you with creating your webiste's backend in node.js. In your case The consumer is your website and The service provider is your nextcloud instance.
Feel free to ask if something seems unclear. Good luck and happy coding!