tentwentyfour / nextcloud-link

Javascript/Typescript client that communicates with Nextcloud's WebDAV and OCS APIs
MIT License
56 stars 7 forks source link

Startup examples #22

Closed FrancisFire closed 3 years ago

FrancisFire commented 4 years ago

It would be nice if there were some useful examples to make this plugin work properly. Tell me if I'm missing any detail as I don't even know where to start.

ghost commented 4 years ago

Hi @FrancisFire, have a look at the tests, they might help you get started until we add some usage examples.

FrancisFire commented 4 years ago

The tests don't seem to be helping at all to be honest

ghost commented 4 years ago

What exactly is your issue, could you provide relevant code snippets please ?

FrancisFire commented 4 years ago

I'd just like to instantiate a new client with parameters such as the webdav's url, an username and a password (hopefully an app's password) and have a check of the connectivity. Some little informations about this simple task are nowhere to be found in this repository. Because of this problem, I don't have any relevant code snippets of mine.

ghost commented 4 years ago
const client = new NextcloudClient({
  username: YOUR_USERNAME,
  password: YOUR_PASSWORD,
  url: YOUR_URL
});

await client.checkConnectivity();

Used in these tests: https://github.com/tentwentyfour/nextcloud-link/blob/master/tests/webdav-jest.ts

FrancisFire commented 4 years ago

Thank you so much. The issue that I'm currently facing is related to url and password. At the moment I'll try using the "/remote.php/webdav" url along with an app password generated from nextcloud. Am I supposed to use these url and password?

ghost commented 4 years ago

Use you nextcloud admin username and password. Use the same url you would use to access your nextcloud instance via browser.

FrancisFire commented 4 years ago

No matter what, I'll always obtain a false boolean value. I'm really trying all the possibilities given by the urls and passwords that I have

ghost commented 4 years ago

Try checking the connectivity every few seconds until it's eventually connected, if it takes longer than 30 seconds, then there's probably either an issue with your credentials or some other issue.

kwisatz commented 4 years ago

Hi @FrancisFire

Thanks for the heads up on the missing examples section, we should definitely add one! If your problem persists, could you please supply a minimal example that we could use to reproduce the problem? Say a docker-compose file (or just the command line to start a single container) for a Nextcloud docker container and your JavaScript or Typescript snippet that tries to establish a connection.