를 사용하여 나는먼저 Google 드라이브 앱 .NET 오류
https://developers.google.com/drive/quickstart-cs#step_3_set_up_the_sample
using System;
using System.Diagnostics;
using DotNetOpenAuth.OAuth2;
using Google.Apis.Authentication.OAuth2;
using Google.Apis.Authentication.OAuth2.DotNetOpenAuth;
using Google.Apis.Drive.v2;
using Google.Apis.Drive.v2.Data;
using Google.Apis.Util;
namespace GoogleDriveSamples
{
class DriveCommandLineSample
{
static void Main(string[] args)
{
String CLIENT_ID = "YOUR_CLIENT_ID";
String CLIENT_SECRET = "YOUR_CLIENT_SECRET";`
// Register the authenticator and create the service
var provider = new NativeApplicationClient(GoogleAuthenticationServer.Description, CLIENT_ID, CLIENT_SECRET);
var auth = new OAuth2Authenticator<NativeApplicationClient>(provider, GetAuthorization);
var service = new DriveService(auth);
File body = new File();
body.Title = "My document";
body.Description = "A test document";
body.MimeType = "text/plain";
byte[] byteArray = System.IO.File.ReadAllBytes("document.txt");
System.IO.MemoryStream stream = new System.IO.MemoryStream(byteArray);
FilesResource.InsertMediaUpload request = service.Files.Insert(body, stream, "text/plain");
request.Upload();
File file = request.ResponseBody;
Console.WriteLine("File id: " + file.Id);
Console.WriteLine("Press Enter to end this process.");
Console.ReadLine();
}
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);
}
}
}
에서 동일한 코드를 촬영 한 ..이 코드에 오류가 있고 오류가 Here입니다 :
The best overloaded method match for
Google.Apis.Drive.v2.DriveService.DriveService(Google.Apis.Services.BaseClientService.Initializer)
has some invalid arguments
Argument 1: cannot convert from
Google.Apis.Authentication.OAuth2.OAuth2Authenticator<Google.Apis.Authentication.OAuth2.DotNetOpenAuth.NativeApplicationClient>
to Google.Apis.Services.BaseClientService.
The call is ambiguous between the following methods or properties:
Google.Apis.Util.Utilities.GetStringValue(System.Enum) and
Google.Apis.Util.Utilities.GetStringValue(System.Enum)
또한 필자의 프로젝트에서 필요한 DLL을 참조합니다.
질문의 범위를 좁히십시오. 이것은 "내 응용 프로그램 디버깅"포럼이 아닙니다. – Mic
var service = new DriveService (auth); 이것은 내 오류 –
입니다. 1 단계에서 다시 시작하십시오. "CLIENT_ID, CLIENT_SECRET"잘못되었습니다.이 두 매개 변수는 값이어야합니다 ... https://developers.google.com/drive/images/clientid-secret.png – JuStDaN