Access OwnCloud File Via OAuth2 Token

Hi, we like to implement a service which will access a file from own-cloud. We can’t use web-dev API because it requires username and password. What we have done is added oAuth2 client for own-cloud with this plugin/app -

https://marketplace.owncloud.com/apps/oauth2

So, our app can have access token with this plugin, but can’t download any file from the server. What we need is to download a user file from the server.

We have tried this- https://github.com/owncloud/gallery/wiki/RESTful-API
but can’t download file with this API also.

Is there any easy way of accessing the own-cloud files from REST API with authentication token provided by OAuth2 client app/plugin?

We have seen a way used in Moodle - https://tracker.moodle.org/browse/MDL-59844

They have actually developed a client (replicated from the own-cloud client) for maintaining REST communication with the own-cloud server.

But it is not a easy way to implement. Is there any official/ authenticated way of doing this?

You could check communication of the ownCloud desktop client using mitmproxy

We like to do something like moodle did, so we need to transfer file from owncloud to our app with oAuth2. My desktop client is working fine. I want to transfer file to my app with OAuth2 from own-cloud. Is there any way?

ownCloud desktop sync client also uses OAuth 2.0 and uses the exact same HTTP methods. With mitmproxy you can see the exact requests and responses and all the headers. Your tool just need to copy them. If you have more detailed questions about one of the methods, I’d be happy to help.

Here you can find the schematics how to get the initial tokens:
https://github.com/owncloud/oauth2/wiki/OAuth-code-Flow-Sequence-Diagram

1 Like