In colab python you can type %sx read -p “hello” and this displays hello and a entry box. The colab swift does not have this functionality which is maybe why we can not enter the gdrive authorisation code.
Also the sample code I copied does not work. The code below does but the Pipe logic above does not work tonight.
import Foundation
let task = Process()
task.executableURL = URL(fileURLWithPath: “/bin/ls”)
task.arguments = ["-al"]
try task.run()
Note the revised URL above I used the whereis command in python !whereis ls to determine the location.
Google has a facility called a service account. This is designed for inter server communication. You create one using console.developers.google.com. You download a JSON.
Inside you will find an email, private key, and information to determine the public key.
Returning to your normal Google Drive you create a share quoting the service account email.
We then paste the JSON into a variable. This creates a security issue because you have just shown your private key.
The next step is to request a access token from Google which lasts for one hour maximum.
This is achieved by taking the email address and SHA256 and signing with the private key.
Google has the public key so verifies your request.
You can then request directory listings of the shared directory, download, upload and delete.
So your swift program can download from Google Drive and store on the local file. Process with Deep Learning and copy the output back to your Google Drive.
I have tested this with a Google Colab session and it worked.