When using this code In my Visual Stuidio Win form project.
var provider = new NativeApplicationClient(GoogleAuthenticationServer.Description, ClientId, C
Yes i got it working.
Install these packages in your project
pm> install-package google.apis -pre
pm> install-package google.apis.drive.v2 -pre
Add these usings
using Google.Apis.Auth.OAuth2;
using Google.Apis.Services;
using System.IO;
using Google.Apis.Drive.v2;
using Google.Apis.Util.Store;
using System.Threading;
private void Form1_Load(object sender, EventArgs e)
{
UserCredential credential;
using (var stream = new FileStream("client_secrets.json", FileMode.Open,
FileAccess.Read)) {
GoogleWebAuthorizationBroker.Folder = "Tasks.Auth.Store";
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
new[] { DriveService.Scope.Drive,
DriveService.Scope.DriveFile },
"user",
CancellationToken.None,
new FileDataStore("Drive.Auth.Store")).Result;
}
}
For google drive i would then create a drive service. You send all the calls against the service. Works the same for google analytics.
BaseClientService service = new DriveService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "Drive API Sample",
});
I expain it all in a blog post: http://daimto.com/google-oauth2-csharp/
If you figuer out how to feed it a stored refrshToken and use that let me know i'm still trying to figuer that out.