I\'m using the Google .NET API to get analytics data from google analytics.
this is me code to start the authentication:
IAuthorizationCodeFlow flow
You basicly need to create your own implimitation of Idatastore and then use that.
IDataStore StoredRefreshToken = new myDataStore();
// Oauth2 Autentication.
using (var stream = new System.IO.FileStream("client_secret.json", System.IO.FileMode.Open, System.IO.FileAccess.Read))
{
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
new[] { AnalyticsService.Scope.AnalyticsReadonly },
"user", CancellationToken.None, StoredRefreshToken).Result;
}
Check here for a basic example of an implimitation of Idatastore. Google Oauth loading stored refresh token
Update:
Several versions of this can be found in my Authentication sample project on GitHub Google-Dotnet-Samples / Authentication / Diamto.Google.Authentication
Update 2