Reputation: 873
I've tried first to store and use the link the API returns, but it expires in a short amount of time. Then I tried to download and store the image locally (and serve it from my servers); but the thumbnail links throws a 404 error when I'm not logged in with my account (though the documents are fully public).
What's the correct way of serving/retrieving the thumbnail of a document?
Upvotes: 3
Views: 1121
Reputation: 21
You need to add the Authorization header to the HTTP GET request for the thumbnailLink URL.
Authorization: OAuth [token]
Replace [token]
with your OAuth token. Without the Authorization header, Google returns a 404 response. Keep in mind the link is not long lived, so you have to grab it quickly.
Upvotes: 0
Reputation: 873
I finally solved the problem. You can download the thumbnails if you fetch the URL before it expires and you use an authenticated client (using the token you have to access the API). This last bit it's important, because a normal GET request will receive a 404 error otherwise.
Upvotes: 2