I’ve been stuck with this for several days. I copied the exact codes from google api samples to upload files to Google Drive. Here is the code
UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
new ClientSecrets
{
ClientId = ClientId,
ClientSecret = ClientSecret,
},
new[] { DriveService.Scope.Drive,
DriveService.Scope.DriveFile },
"user",
CancellationToken.None,
new FileDataStore("MyStore")).Result;
But it will throw an exception at runtime: Method not found: "Void Google.Apis.Util.Store.FileDataStore..ctor (System.String)". I have already added the necessary Google Api DLLs.
Or, if someone can offer the best code to upload files to Google Drive on a website that implements server-side authorization. Any help would be greatly appreciated.
UPDATE: I changed the code to this
var token = new TokenResponse { RefreshToken = "1/6hnki1x0xOMU4tr5YXNsLgutzbTcRK1M-QOTEuRVxL4" };
var credentials = new UserCredential(new GoogleAuthorizationCodeFlow(new GoogleAuthorizationCodeFlow.Initializer
{
ClientSecrets = new ClientSecrets
{
ClientId = ClientId,
ClientSecret = ClientSecret
},
Scopes = new[] {
DriveService.Scope.Drive, DriveService.Scope.DriveFile
}
}), "user", token);
But it also throws an exception: Method not found: "Void Google.Apis.Auth.OAuth2.Flows.GoogleAuthorizationCodeFlow..ctor (Initializer). Is there a problem with the dll?