nextcloud / Android-SingleSignOn

Single sign-on for Nextcloud (Android Library Project)
GNU General Public License v3.0
71 stars 30 forks source link

Access not possible when using a HTTP redirect #200

Open christianlupus opened 4 years ago

christianlupus commented 4 years ago

I have an NC installation that was relocated in the past. To keep things for older installations/users working I added an HTTP redirect (302 at the moment). This breaks the notes app on android. I contacted the developer there and he tells me that he uses this library in order to do all network-based stuff. He asked me to open an issue here to ake you aware of the issue.

Here is the information I got from the app: ``` App Version: 2.11.8 App Version Code: 2011008 App Flavor: play Files App Version Code: 30110151 --- OS Version: 3.0.31-1678704(N8000XXSDQA7) OS API Level: 19 Device: p4noterf Manufacturer: samsung Model (and Product): GT-N8000 (p4noterfxx) --- com.nextcloud.android.sso.exceptions.NextcloudHttpRequestFailedException: HTTP-Anfrage ist fehlgeschlagen mit HTTP-Statuscode: 302 at com.nextcloud.android.sso.api.AidlNetworkRequest.performNetworkRequestV2(AidlNetworkRequest.java:172) at com.nextcloud.android.sso.api.NextcloudAPI.performNetworkRequestV2(NextcloudAPI.java:148) at it.niedermann.owncloud.notes.persistence.NotesClient.requestServer(NotesClient.java:162) at it.niedermann.owncloud.notes.persistence.NotesClient.getNotes(NotesClient.java:98) at it.niedermann.owncloud.notes.persistence.NoteServerSyncHelper$SyncTask.pullRemoteChanges(NoteServerSyncHelper.java:446) at it.niedermann.owncloud.notes.persistence.NoteServerSyncHelper$SyncTask.doInBackground(NoteServerSyncHelper.java:358) at it.niedermann.owncloud.notes.persistence.NoteServerSyncHelper$SyncTask.doInBackground(NoteServerSyncHelper.java:320) at android.os.AsyncTask$2.call(AsyncTask.java:288) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) at java.lang.Thread.run(Thread.java:841) Caused by: java.lang.IllegalStateException: 302 Found

Found

The document has moved here.

at com.nextcloud.android.sso.InputStreamBinder.processRequestV2(InputStreamBinder.java:438) at com.nextcloud.android.sso.InputStreamBinder.performNextcloudRequestAndBodyStreamV2(InputStreamBinder.java:135) at com.nextcloud.android.sso.InputStreamBinder.performNextcloudRequestV2(InputStreamBinder.java:118) at com.nextcloud.android.sso.aidl.IInputStreamService$Stub.onTransact(IInputStreamService.java:134) at android.os.Binder.execTransact(Binder.java:404) at dalvik.system.NativeStart.run(Native Method) ``` I only changed the URL domain in the backtrace.

If you need more information or anything I can provide, please let me know.

stefan-niedermann commented 2 years ago

@christianlupus can you please try again with Nextcloud Android 3.17 and Notes Android 3.2.5 or higher?

Please make sure to clear the storage of the Notes app properly as described in our FAQ - a deinstallation and reinstallation is not the same. Please also remove and readd your account in the Nextcloud Android app.

Finally: Please name the exact version of yoir server side Notes app - it should be 4.1.1.

newhinton commented 2 years ago

I have the same issue. I am trying to access the cookbook api, which results in a 302 redirect, and the request fails. The strange thing is that there should not be a redirect, the api should return the properly sized image on that endpoint. The request is made with performNetworkRequestV2 using Android-SingleSignOn:0.6.0

val url = "/apps/cookbook/recipes/$recipe_id/image?size=thumb"
...
val nextcloudRequest: NextcloudRequest = NextcloudRequest.Builder()
    .setMethod("GET")
    .setUrl(url)
    .build()

I then tried to switch to the Parameter-based query, but this fails with a different error

var size = "thumb"
val url = "/apps/cookbook/recipes/$recipe_id/image"
...
val parameters = Collections.singleton(QueryParam("size", size))
        val nextcloudRequest: NextcloudRequest = NextcloudRequest.Builder()
            .setMethod("GET")
            .setUrl(url)
            .setParameter(parameters)
            .build()

Error, just for completeness sake com.nextcloud.android.sso.exceptions.UnknownErrorException: com.nextcloud.android.sso.QueryParam; local class incompatible: stream classdesc serialVersionUID = 21523240203234211, local class serialVersionUID = -2413260979044997003