Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

401 Unauthorized POST https://www.googleapis.com/upload/drive/v3/files?fields=id&uploadType=resumable #125

Closed
warrenarnold opened this issue Feb 10, 2023 · 7 comments

Comments

@warrenarnold
Copy link

Hello, firstly thanks for posting this software its very handy.

We have run into an issue syncing with one account, we are recieving the below message when trying to authenticate by with the simple authentication and by the json method.

401 Unauthorized POST https://www.googleapis.com/upload/drive/v3/files?fields=id&uploadType=resumable

image

We are using this on Windows and have tried running this on different computers with the same result.

The only difference I can see is this is a Google Workspace managed email account. Is there other steps/settings we need to follow to get it to work on this account?

I have also put a snip of the last few lines of the log file below if that helps.

Looking forward to your reply.

2023-02-10T09:17:10,156 ERROR [JavaFX Application Thread] n.y.g.u.UploadPaneControllerImpl Upload failed java.util.concurrent.CompletionException: java.lang.RuntimeException: com.google.api.client.googleapis.json.GoogleJsonResponseException: 401 Unauthorized POST https://www.googleapis.com/upload/drive/v3/files?fields=id&uploadType=resumable at java.util.concurrent.CompletableFuture.encodeThrowable(Unknown Source) ~[?:?] at java.util.concurrent.CompletableFuture.completeThrowable(Unknown Source) ~[?:?] at java.util.concurrent.CompletableFuture$AsyncSupply.run(Unknown Source) ~[?:?] at com.google.common.util.concurrent.DirectExecutor.execute(DirectExecutor.java:30) ~[guava-30.1.1-jre.jar:?] at java.util.concurrent.CompletableFuture.asyncSupplyStage(Unknown Source) ~[?:?] at java.util.concurrent.CompletableFuture.supplyAsync(Unknown Source) ~[?:?] at net.yudichev.jiotty.connector.google.drive.InternalGoogleDrivePath.createFile(InternalGoogleDrivePath.java:60) ~[jiotty-connector-google-drive-2.2.2.jar:?] at net.yudichev.googlephotosupload.core.DriveSpaceTrackerImpl.lambda$refreshDriveQuota$9(DriveSpaceTrackerImpl.java:117) ~[app-2.0.5.jar:2.0.5] at net.yudichev.googlephotosupload.core.CloudOperationHelperImpl.withBackOffAndRetry(CloudOperationHelperImpl.java:26) ~[app-2.0.5.jar:2.0.5] at net.yudichev.googlephotosupload.core.DriveSpaceTrackerImpl.refreshDriveQuota(DriveSpaceTrackerImpl.java:115) ~[app-2.0.5.jar:2.0.5] at net.yudichev.googlephotosupload.core.DriveSpaceTrackerImpl.lambda$reset$0(DriveSpaceTrackerImpl.java:61) ~[app-2.0.5.jar:2.0.5] at net.yudichev.jiotty.common.lang.Locks.inLock(Locks.java:13) ~[jiotty-common-2.2.2.jar:?] at net.yudichev.googlephotosupload.core.DriveSpaceTrackerImpl.lambda$reset$1(DriveSpaceTrackerImpl.java:58) ~[app-2.0.5.jar:2.0.5] at java.util.concurrent.CompletableFuture$AsyncSupply.run(Unknown Source) ~[?:?] at java.util.concurrent.CompletableFuture$AsyncSupply.exec(Unknown Source) ~[?:?] at java.util.concurrent.ForkJoinTask.doExec(Unknown Source) ~[?:?] at java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(Unknown Source) ~[?:?] at java.util.concurrent.ForkJoinPool.scan(Unknown Source) ~[?:?] at java.util.concurrent.ForkJoinPool.runWorker(Unknown Source) ~[?:?] at java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source) ~[?:?] Caused by: java.lang.RuntimeException: com.google.api.client.googleapis.json.GoogleJsonResponseException: 401 Unauthorized POST https://www.googleapis.com/upload/drive/v3/files?fields=id&uploadType=resumable at net.yudichev.jiotty.common.lang.MoreThrowables.getAsUnchecked(MoreThrowables.java:19) ~[jiotty-common-2.2.2.jar:?] at net.yudichev.jiotty.connector.google.drive.InternalGoogleDrivePath.lambda$createFile$4(InternalGoogleDrivePath.java:61) ~[jiotty-connector-google-drive-2.2.2.jar:?] ... 18 more Caused by: com.google.api.client.googleapis.json.GoogleJsonResponseException: 401 Unauthorized POST https://www.googleapis.com/upload/drive/v3/files?fields=id&uploadType=resumable at com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:146) ~[google-api-client-1.31.5.jar:1.31.5] at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:118) ~[google-api-client-1.31.5.jar:1.31.5] at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:37) ~[google-api-client-1.31.5.jar:1.31.5] at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:532) ~[google-api-client-1.31.5.jar:1.31.5] at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:455) ~[google-api-client-1.31.5.jar:1.31.5] at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:565) ~[google-api-client-1.31.5.jar:1.31.5] at net.yudichev.jiotty.connector.google.drive.InternalGoogleDrivePath.lambda$createFile$3(InternalGoogleDrivePath.java:68) ~[jiotty-connector-google-drive-2.2.2.jar:?] at net.yudichev.jiotty.common.lang.MoreThrowables.getAsUnchecked(MoreThrowables.java:17) ~[jiotty-common-2.2.2.jar:?] at net.yudichev.jiotty.connector.google.drive.InternalGoogleDrivePath.lambda$createFile$4(InternalGoogleDrivePath.java:61) ~[jiotty-connector-google-drive-2.2.2.jar:?] ... 18 more

@ylexus
Copy link
Owner

ylexus commented Feb 15, 2023

Hi, have you granted all required permissions to the app during login? If not if you don't remember, Can you try logging out and then in via the menu and grant all permissions?

I'll have a closer look in a few days. The problem is with the permissions to the Google Drive, which is need to display your remaining google storage space. This does not work reliably anyway, so if it creates issues I may be able to disable it to prevent the problem from blocking the user from using the app.

@ylexus
Copy link
Owner

ylexus commented Feb 16, 2023

@warrenarnold I tried denying the app the "drive" permission, however it results in a different, clearer error. Can you still try to re-login, if not already tried, and let me know what the result is?
Screenshot 2023-02-16 at 09 08 26

@warrenarnold
Copy link
Author

Thanks for your reply.

Yes we are granting all permissions when using the simple authentication method ... and we followed all your instructions to allow all the settings when trying the advanced method with a Client ID.

Yes we have tried logging out and back in again and tried it on different PCs with the same result.

@ylexus
Copy link
Owner

ylexus commented Mar 11, 2023

Hi, just letting you know that I am having very limited amount of free time these days. This work is currently sitting at the bottom of my TODO list.
In general, it's unlikely that I'll be fixing the root cause - it's unclear why on that particular account google decides to fail when attempting create an app-specific file on Drive. What I'll do is I'll just make a small change to ignore failures in this area as all this is needed for is to display the amount of free Google Storage, which is non-essential.

@warrenarnold
Copy link
Author

Thanks for your reply, I ended up getting it to work ok, just needed to allow API access to upload to that account in the Google Console.

Thanks again for the great software.

One feature that would make it even better is:

If you choose to upload folders as albums to a limited depth (2 deep) but its uploading photos from the 3rd or 4th level folders then still put them into the level 2 folder but add the sub-sub-folder names to the photo description text, currently the description text is just the photo file name.

Sometimes the subfolders are organized with folder names that would be useful to have in Google Photos so they can be searched, but don't qualify to have their own album.

@warrenarnold
Copy link
Author

In case anyone else gets stuck with this:

To allow Jiotty Uploader to work with a Gsuite account...

Go to Google Admin Console > Apps > Google Workspace > Settings for Drive and Docs > Features and Applications > Drive SDK > Click Allow.

Once allowed it will work.

@warrenarnold
Copy link
Author

In case anyone else gets stuck with this:

To allow Jiotty Uploader to work with a Gsuite account...

Go to Google Admin Console > Apps > Google Workspace > Settings for Drive and Docs > Features and Applications > Drive SDK > Click Allow.

Once allowed it will work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants