I try to allow users to select images from the users google drive. I follow this doc: https://developers.google.com/picker/docs/. When i recive the image url from google ('/drive/v2/files/' + FileId) then i try to download tile image in my .NET code:
var WebRequest = (HttpWebRequest)System.Net.WebRequest.Create(url);
WebRequest.AllowWriteStreamBuffering = true;
WebRequest.Timeout = 30000;
WebRequest.KeepAlive = false;
WebRequest.UserAgent = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36";
WebRequest.AllowAutoRedirect = true;
WebRequest.Headers.Add("Authorization", "Bearer " + token);
byte[] Arr;
using (var WebResponse = WebRequest.GetResponse())
{
using (var Stream = WebResponse.GetResponseStream())
{
Arr = Stream.StreamToByteArray();
}
WebResponse.Close();
}
return Arr;
But all i get is a empty (white) webpage. With the url i get from google, i can se the image in my browser, but i cant download it in my code.
How can i get the image downloaded?