Google .NET APIs - any other DataStore other than the FileDataStore?

后端 未结 5 1377

I\'m using the Google .NET API to get analytics data from google analytics.

this is me code to start the authentication:

IAuthorizationCodeFlow flow          


        
5条回答
  •  Happy的楠姐
    2020-12-14 02:20

    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

    • Updated database datastore exmaples

提交回复
热议问题