我想在身份验证文件夹查询行发送错误后从 google-drive 迭代文件夹。下面的代码显示身份验证过程,然后 itretating 文件夹但出现错误,请帮助我,等待回复。我不想在编码中使用用户凭据,我想使用客户端 ID 和客户端密码,以便任何人都可以登录到 Google 驱动器并迭代文件夹。
“请求执行失败:https ://docs.google.com/feeds/default/private/full/-/folder ”
static void Main(string[] args)
{
String CLIENT_ID = "74138000159.com";
String CLIENT_SECRET = "8AE3oJuZomO";
var provider = new NativeApplicationClient(GoogleAuthenticationServer.Description, CLIENT_ID, CLIENT_SECRET);
var auth = new OAuth2Authenticator<NativeApplicationClient>(provider, GetAuthorization);
var service = new DriveService(auth);
DocumentsService service1 = new DocumentsService("MyDocumentsListIntegration-v1");
// Instantiate a FolderQuery object to retrieve folders.
FolderQuery query = new FolderQuery();
// Make a request to the API and get all documents.
DocumentsFeed feed = service1.Query(query);
// Iterate through all of the documents returned
foreach (DocumentEntry entry in feed.Entries)
{
// Print the title of this document to the screen
Console.WriteLine(entry.Title.Text);
}
}
private static IAuthorizationState GetAuthorization(NativeApplicationClient arg)
{
// Get the auth URL:
IAuthorizationState state = new AuthorizationState(new[] { DriveService.Scopes.Drive.GetStringValue() });
state.Callback = new Uri(NativeApplicationClient.OutOfBandCallbackUrl);
Uri authUri = arg.RequestUserAuthorization(state);
// Request authorization from the user (by opening a browser window):
Process.Start(authUri.ToString());
Console.Write(" Authorization Code: ");
string authCode = Console.ReadLine();
Console.WriteLine();
// Retrieve the access token by using the authorization code:
return arg.ProcessUserAuthorization(authCode, state);
}