Call Google Spreadsheet by bash - bash

I would like to call my private google spreadsheet by bash/shell. I don't want to edit it or something, only read it and put the content on the stand-output...
Is it possible?
I found a way, where I can call published projects from Google Drive, but that doesn't fit, as I have confidential data in that spreadsheet!
Also I haven't find an easy to use API solution to do that one simple thing.
Thanks!

Yes it's possible.
Your script will need to do 3 things, each with curl:-
Use a saved Refresh Token to request an Access Token
Use the Access Token to fetch your spreadsheet's File resource (json)
Parse the json to extract the exportLinks object, and choose which format (eg. csv) you want to download
GET that exportLink

Related

Structure of amadeus api https

usualy when I use API's I paste the entire url in browser and it print it out json format using json pro extension in chrome. Like this is a lot easier to copy the path of some data and render it to the page.But my problem is I don't know structure of https. I am not sure where I have to insert the key and secret code. In command line I print all data but I cannot get the path of specific data without using json probextension. Help please. Thank you
I recommend to read the following article:
https://developers.amadeus.com/self-service/apis-docs/guides/authorization-262
and later, review the following repository, you could tinker with the curl request here:
https://github.com/amadeus4dev/amadeus-code-examples
https://github.com/amadeus4dev/amadeus-code-examples/blob/master/airline_code_lookup/v1/get/curl/airline_code_lookup.sh

FFMPEG using Google Drive API instead of Shared URL

We are using FFMPEG to stream a Google Drive URL into a node application.
Is there an FFMPEG method or library we can use to stream to FFMPEG using the Google Drive API instead of using the standard public shared URL?
At the moment using the URL works fine if the file size is <100mb but with bigger files we get an error:
https://drive.google.com/uc?export=download&id=fileId: Invalid data found when processing input
This is because we reach the pesky gDrive virus roadblock page:
From your question, I understood that your file is publicly shared. In this case, when the file size becomes large, the endpoint of https://drive.google.com/uc?export=download&id=fileId is required to be processed with 2 steps. Ref This has already been also mentioned in your question.
In this answer, in order to avoid this, I would like to propose to use the method of "Files: get" in Drive API and the API key. When Drive API and API key is used for the publicly shared file, no 2 step flow is required, and it can use it by changing only the URL.
Endpoint:
https://www.googleapis.com/drive/v3/files/{fileId}?alt=media&key={your API key}
For example, as a test, when you use curl command, you can use curl "https://www.googleapis.com/drive/v3/files/{fileId}?alt=media&key={your API key}".
References:
Download a file stored on Google Drive
Files: get
Using API keys

Google Drive API v3 : there isn't any way to get a download url for a google document?

The Google Drive API v2 to v3 migration guide says:
The exportLinks field has been removed from files. To export Google Documents, use the files.export method instead.
I don't want to export (download) the file right away. "files.export" will actually download the file. I want a link to download the file, later. This was possible in v2 by means of the exportLinks.
How can I in v3 accomplish the same? If it is not possible, why was this useful feature removed?
Besides, (similar problem to above) downloadUrl was also removed, and the suggested alternative ("files.get with ?alt=media") downloads the file instead of providing a download link. This means there is no way in v3 to get a public short lived URL for a file?
EDIT:
there is no way in v3 to get a public short lived URL for a file?
For regular files, apparently yes.
This seems to work fine (a public short lived link to the file with its right name and contents):
https://www.googleapis.com/drive/v3/files/ID?alt=media&access_token=TOKEN
For google apps files, no (not even private, as v2 exportLinks used to be).
https://www.googleapis.com/drive/v3/files/ID/exportmimeType=TYPEv&access_token=TOKEN
Similar to regular files, this URL is a short lived link to the file contents, but lacking of its right name.
BTW, I see the API is not behaving consistently: /drive/v3/files/FILEID delivers the right file name, but /drive/v3/files/FILEID/export does not.
I think the API itself should be setting the right Content-Disposition, as it is apparently doing when issuing a /drive/v3/files/FILEID call.
This file naming problem invalidates the workaround to the lack of ExportLinks in v3.
The v2 ExportLinks allowed me to link a file (which is not the same as getting its content right away). Anyone logged in and with the proper permissions was able to access it, and the link didn't needed any access_token, and it wasn't short lived. It was good and useful.
Building a link with a raw API call like /drive/v3/files/FILEID/export (with mandatory access_token) would be an close enough workaround (it is temporary and public, not the same as it was, anyway). However, the naming problem invalidates it.
In v2, regular files have a WebContentLink and google apps files have exportLinks. In v3 exportLinks are gone, and I don't see any suitable alternative to them.
Once you query for your file by id you can use the function getWebContentLink() to get the download link of the file (eg. $file->getWebContentLink() ).
I think you're placing too much emphasis on the word "method".
There is still a link to export a file, it's https://www.googleapis.com/drive/v3/files/fileIdxxxxx/export&mimeType=xxxxx/xxxxx. Make sure you URL encode the mime type.
Eg
https://www.googleapis.com/drive/v3/files/1fGBQ81haNU_nEiC5GITZD3bxT0ppL2LHg-C0ubD4Q_s/export?mimeType=text/csv&access_token=ya29.Gmo0BMvO-pVEPKsiD9j4D-NZVGE91MChRvwOcBSg3cTHt5uAClf-jFxcovQScbO2QQhwHS95eSGW1eQQcK5G1UQ6oI4BFEJJkntEBkgriZ14GbHuvpDL7LT2pKA--WiPuNoDDIuZMm5lWtlr
These links form part of the API, so the expectation is that you've written a client that sends authenticated requests, and deals with the response data. This explains why, if you simply paste the link into a browser without an access_token, it will fail. It also explains why the filename is export, ie. it isn't intended that your client would ever use a filename, but rather it should receive the data as a stream. This SO answer discusses the situation in more detail How to set name of file downloaded from browser?

How can I generate TempURL for object on Object Storage of SoftLayer

How can I generate TempURL for object on Object Storage of SoftLayer?
I currently use Ruby API and I can access my object after authenticate.
But for external End Users, I need to generate public URL for that object which is can be accessed without authentication process.
I tried to generate Temp URL with expiration, but I cannot find key for hexdigest() of HMAC. How can I found it? or is there any other way to get same result?
I can do it using the swift client like this:
We add the temporary urls secret keys with the command:
$ swift post -m "Temp-URL-Key:mykey"
We create the temporary URL:
$ swift-temp-url GET 3600 /v1/AUTH_d684780d-aafe-4772-bcbb-0f07d5f6edf3/a-container/data.txt mykey
it returns:
v1/AUTH_d684780d-aafe-4772-bcbb-0f07d5f6edf3/a-container/data.txt?temp_url_sig=19f067d38dc532883e8f02be3b43a172c61e51d2&temp_url_expires=1445615769
Then we can access to the file:
curl 'https://dal05.objectstorage.softlayer.net/v1/AUTH_d684780d-aafe-4772-bcbb-0f07d5f6edf3/a-container/data.txt?temp_url_sig=19f067d38dc532883e8f02be3b43a172c61e51d2&temp_url_expires=1445615769'
Some reference pages:
Here how to install and configure the swift client
http://sldn.softlayer.com/es/blog/waelriac/Managing-SoftLayer-Object-Storage-Through-REST-APIs
here how to create the temp URL
http://luisbg.blogalia.com/historias/74348
I hope it helps
Answer myself.
I finally wrote a code for it, after doing some more search on it including:
read related API codes from https://github.com/softlayer/softlayer-object-storage-ruby
read http://sldn.softlayer.com/es/blog/waelriac/Managing-SoftLayer-Object-Storage-Through-REST-APIs
after that, I found some hint from middle of the second document: the response Header contains this key!
X-Account-Meta-Temp-URL-Key
So, I wrote a code(method) for it and make pull request(https://github.com/softlayer/softlayer-object-storage-ruby/pull/10), and I hope it will merged soon.
anyway, If it is not accepted (yet), you can found my code at https://github.com/c12g/softlayer-object-storage-ruby

Programatically retrieve an attachment stored on a note on a CRM 4.0 entity

How would you suggest working with files that is stored on the note of a entity in Crm. Could you write a generic method that will enable you to access any type of file? Or would it be better to have a method for dealing with each type of file?
For example, we are going to be saving a mix of swf files and xml files on the entity, so would it make sense to have a method each for example:
GetXmlFilesOnAccount(accountid)
GetSwfFilesOnAccount(accountid)
When you upload an attachment to CRM the mimetype is also saved as part of the record information.
The following link contains a nice example of how to download the attachemt using a single method. http://crmscape.blogspot.com/2009/10/ms-crm-40-sending-attachments-to.html
The post is missing the actual query needed to retrieve the annotations but you can tell what columns are required from the method signature.
My suggestion using your methods:
* GetXmlFilesOnAccount(accountid)
* GetSwfFilesOnAccount(accountid)
Retrieve account activitypointers by regardingobjectid(in your case accountid guid)
Loop through returned activitypointers
Get attachments for each activitypointer (activitypointer.activityid = activitymimeattachment.activityid)
Store attachments (disk, etc)
You don't even need two methods. You can retrieve all attachment file types for a given note (annotation) with a single method.
Hope this helps.
I recently started an Open Source Project on CodePlex to accomplish exactly that. Feel free to check out the Project's Web Page at:
http://crmattachdownload.codeplex.com/
You can also view the source code under the "Source Code" tab of that same page.
Pete

Resources