我正在使用来自 C# 的请求代码并得到一个错误的请求结果:
public class GoogleDriveManager
{
private static readonly HttpClient Client = new HttpClient();
private const string Access = "ACCESS";
public GoogleDriveManager()
{
Client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Access);
}
public async Task<HttpResponseMessage> GetFilesAsync(string driveId)
{
var url =
$"https://www.googleapis.com/drive/v3/files?driveId={driveId}&includeItemsFromAllDrives=true&corpora=true&supportsAllDrives=true";
var result = await Client.GetAsync(url);
return result;
}
}
但是当我从邮递员那里提出同样的请求时,效果很好:
获取 https://www.googleapis.com/drive/v3/files?driveId=DRIVEID&includeItemsFromAllDrives=true&corpora=drive&supportsAllDrives=true
(授权持有者令牌,令牌值与上面使用的令牌相同(
我在 C# 方面做错了什么?
根据 API 文档,语料库支持的值为:
- 用户
- 域
- 驾驶
- 所有驱动器
您的邮递员示例具有 corpora=drive,但您的 C# 示例显示 corpora=true。