title: How to Download file from Google drive in WPF - installed application
body: <p>I am developing WPF application and in this I am implementing Google Drive API with Upload and Download functionality. The Upload is working fine but I am facing problem in downloading the document. I looked at the code in Google document at <a href="https://developers.google.com/drive/web/manage-downloads" rel="nofollow">https://developers.google.com/drive/web/manage-downloads</a></p>
  
  <pre><code> public static System.IO.Stream DownloadFile(IAuthenticator authenticator, File file) 
   {
     if (!String.IsNullOrEmpty(file.DownloadUrl)) 
     {
       try {
         HttpWebRequest request = (HttpWebRequest)WebRequest.Create(new Uri(file.DownloadUrl));
         authenticator.ApplyAuthenticationToRequest(request);
         HttpWebResponse response = (HttpWebResponse) request.GetResponse();
         if (response.StatusCode == HttpStatusCode.OK) 
         {
            return response.GetResponseStream();
         }
         else
         {
            Console.WriteLine("An error occurred: " + response.StatusDescription);
            return null;
         }
      }
      catch (Exception e) 
      {
        Console.WriteLine("An error occurred: " + e.Message);
        return null;
      }
    }
    else
    {
      // The file doesn't have any content stored on Drive.
      return null;
    }
  </code></pre>
  
  <p>}</p>
  
  <p>But according to this document
  "<a href="https://code.google.com/p/google-api-dotnet-client/source/browse/Src/GoogleApis/Apis/Authentication/IAuthenticator.cs?r=e6585033994bfb3a24d4c140db834cb14b9738b2" rel="nofollow">https://code.google.com/p/google-api-dotnet-client/source/browse/Src/GoogleApis/Apis/Authentication/IAuthenticator.cs?r=e6585033994bfb3a24d4c140db834cb14b9738b2</a>"
  it is showing that "IAuthenticator is not supported any more" and thus the above code is not working. </p>
  
  <p>I tried of using UserCredential but it is throwing "The remote server returned an error: (401) Unauthorized.".</p>
  
  <p>So please provide code for the same in WPF application or how can I download any type of file from Google drive.</p>