Getting a link to a file uploaded to google drive

Hi all!
I have a workflow at the end of which files are uploaded from a specific folder(local) to google drive, having previously archived it into one zip file.
Below is an illustration of this part of the workflow.
So, I have a simple task for which I can’t find a solution - I want to get a link to this file, I mean a direct link to google drive which I can share.

I tried the python script from this post: Getting ID's from google drive folder , but this solution is quite complicated for such a simple task and after I was finally able to implement it, it stopped working for some unknown reason…

knime example

Hi @Cor4win, welcome to the Forum!

I don’t think there is any native node to get the URL for the file in Google Drive. @duristef solution looks reliable. What error are you receiving when running the code?

Regards,
Wali

1 Like

Error text: “Execute failed: Autorized user info was not in the expected format, missing fields refresh_token.”
The first time the node was launched, everything was successful - I logged in my google using the link that opened in the browser, but the next launches of the node lead to this error.

Have you refreshed your Authentication token? They tend to expire frequently.

1 Like

I don’t know how to do it, I’m using oauth for the first time… should I add some code to python script node?

Hi @Cor4win , basically you just need to re-run the node that requests the token.

You either need to optimize your workflow to make sure the token is not requested too early - that way it has less risk of expiring before it’s needed, or just make another request (copy the node and add the copy further down the workflow) to get a new token.

Of course I tried to re-run the node. I mean, what can be expired if I start the node right after its reset and get an error? Like this:
image

It looks like the code isn’t picking up your token for some reason, or it is expired. You may want to recreate the tokens.json or explicitly path to it in the Python snippet outlined Python Quickstart  |  Drive API  |  Google Developers

I figured this out. When you start the node with python script for the first time, a token.json is created in the workflow directory, and if you copy the node to another workflow you must copy this token to the workflow directory too (to which the token was copied). Otherwise, the token in the new workflow is re-created and something goes wrong…

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.