Unable to retrieve file content from google drive API

前端 未结 2 1435
南方客
南方客 2020-12-10 05:24

I seem to be unable to retrieve the content of a file via the google drive SDK. To reproduce the problem I use the API explorer to get the meta data for a small text file:

2条回答
  •  暖寄归人
    2020-12-10 05:34

    Try to use below code for request

    var service1=SetCredential();
    var AccessToken=((Google.Apis.Auth.OAuth2.UserCredential)service1.HttpClientInitializer).Token.AccessToken;
    String link = "https://www.googleapis.com/drive/v2/files/" + fileId ;
    
    HttpWebRequest request = WebRequest.Create(link) as HttpWebRequest;
    request.Method = "GET";
    request.Headers.Add("Authorization", "Bearer " + AccessToken);
    WebResponse response = request.GetResponse();
    

提交回复
热议问题