Hello,
So today I've started looking at the Google Drive api since i wanna integrate google drive in my application.
I followed the quick start guide for .NET and received my access token from the program that I was told to copy/paste from the guide.
My next step is to try and download a file from my google drive account. I go to google drive, fetch the id, copy&paste the token from earlier and create a simple c# program as follows:
HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "accessTokenFromQuickstartprogram");
client.DefaultRequestHeaders.Accept.Clear();
HttpRequestMessage sendRequest = new HttpRequestMessage(HttpMethod.Get, client.BaseAddress);
HttpResponseMessage response = client.SendAsync(sendRequest).Result;
string result = response.Content.ReadAsStringAsync().Result;
Console.WriteLine(response);
Console.WriteLine(result);
I followed the documentation here (
https://developers.google.com/drive/v3/web/manage-downloads), add a ?alt=media to the URL in order to download and authorize my request by adding the header. From this request i get status code "200 - OK" but there's no response but the string in the text file that i tried to download - i kinda expected a download URL of some sort since im trying to download the file?
Entire response:
StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
X-GUploader-UploadID: someNumber
Vary: Origin
Vary: X-Origin
X-Goog-Hash: crc32c=z35Mtg==
Alt-Svc: quic=":443"; ma=2592000; v="35,34"
Cache-Control: must-revalidate, max-age=0, private
Date: Mon, 23 Jan 2017 15:53:22 GMT
Server: UploadServer
Content-Length: 14
Content-Disposition: attachment
Content-Type: text/plain
Expires: Mon, 23 Jan 2017 15:53:22 GMT
}
Am I doing something wrong trying to download a file using the Google Drive api? Thoughts?