pCloud / pcloud-sdk-java

The official pCloud Java SDK repository
https://pcloud.github.io/pcloud-sdk-java/
Apache License 2.0
39 stars 14 forks source link

How to list shared folders with Java SDK #33

Closed PhilippC closed 11 months ago

PhilippC commented 2 years ago

I am calling ApiClient.listFolder using the Java SDK. While https://my.pcloud.com/ shows a folder shared by another user, the listFolder call does not include this shared folder. How can I list/access this folder using the Java SDK?

georgi-neykov-hub commented 2 years ago

@PhilippC , the current version of the SDK does not list folders and files coming from shares. To work, a few properties should be added to RemoteEntry so that SDK consumers can tell the access permissions and ownership for each folder/file. I will reach out with some updates in the beginning of next week, expect a new version for the SDK library at some point in end of Monday/ mid-Thursday.

georgi-neykov-hub commented 2 years ago

@PhilippC , version 1.8.0 of the library is live with the necessary changes to make shared folders visible. I will keep the issue open waiting for feedback.

PhilippC commented 2 years ago

after updating to 1.8.1 (from 1.2.0) I needed to change my code replacing the line

        Intent authIntent = AuthorizationActivity.createIntent(castedActivity, this.clientId);

with

        AuthorizationRequest req = AuthorizationRequest.create()
                .setClientId(this.clientId)
                .setType(AuthorizationRequest.Type.TOKEN)
                .setForceAccessApproval(true)
                .build();

        Intent authIntent = AuthorizationActivity.createIntent(castedActivity, req);

Unfortunately, I now get "This 'redirect_uri' is not authorized":

image

As it is working with 1.2.0 I suspect that my app configuration is correct, but maybe I'm not using the AuthorizationRequest not correctly?

sixtsense commented 2 years ago

@PhilippC As of version 1.5.0 of the pCloud Java SDK there have been changes to the Uri scheme required for the redirect to work. You must change the redirect Uri in your pCloud application (https://docs.pcloud.com/my_apps/) to - 'pcloud-oauth://{your.application.package}'

PhilippC commented 2 years ago

👍 that solved my issue.

Accessing shared folders is now working, thanks a lot!

PhilippC commented 1 year ago

unfortunately I never found the time to integrate this feature in my app. Now I finally wanted to do so and made some changes to the code, so it should work with access to the full pCloud (previously I only offered Applications-folder access) and I was expecting shared folders to work as well. I created a shared folder from a different pCloud account and it shows with this icon in my.pcloud.com:

grafik

Unfortunately, listFolder does not return an element in children() for this folder. Do I need to do something differently?

georgi-neykov-hub commented 1 year ago

@PhilippC let me build a sample with shared folders and I will reach out.

PhilippC commented 1 year ago

As of version 1.5.0 of the pCloud Java SDK there have been changes to the Uri scheme required for the redirect to work. You must change the redirect Uri in your pCloud application (https://docs.pcloud.com/my_apps/) to - 'pcloud-oauth://{your.application.package}'

While trying to make this change to the production app, I realized that the app was created by one of the contributors and not myself. Unfortunately his account seems to be deleted (https://github.com/PhilippC/keepass2android/pull/2388#issuecomment-1799771771). Is it possible to move the app to my pCloud account or at least restore his account? The app is used by >1.000.000 users (not all of them use pCloud of course, but it should still be quite a few). I would like to avoid them having to re-authenticate if I change the clientId. (Sorry for asking this here but I didn't find a better contact point)

PhilippC commented 1 year ago

@georgi-neykov-hub any news on this?

sixtsense commented 12 months ago

Hello @PhilippC, sorry for the delayed response. A new version of the pcloud-java-sdk (1.9.1) addressing this issue should soon be available in maven central. In it shared folders should be listed alongside regular folders when calling ApiClient.listFolder & ApiClient.loadFolder methods. For your other issue concerning the ownership of the OAuth app, please contact support@pcloud.com for further assistance.

PhilippC commented 11 months ago

@georgi-neykov-hub Can you maybe still share the example you mentioned in https://github.com/pCloud/pcloud-sdk-java/issues/33#issuecomment-1794466752?

sixtsense commented 11 months ago

Hello, @PhilippC as my last comment stated, a new version of the pcloud-java-sdk (1.9.1) is now available to download from maven central. Simply updating to it should resolve the main issue described in https://github.com/PhilippC/keepass2android/issues/2474 (shared folder should now be visible for Bob's account)

PhilippC commented 11 months ago

thanks for the hint and the update!