我有一个在Web服务器IIS上运行的Web应用程序,因此要初始化服务,我们需要GoogleAuthorizationCodeFlow而不是GoogleWebAuthorizationBroker。
创建服务对象时,HttpClientInitializer
应该传递什么内容?
var flow = new GoogleAuthorizationCodeFlow(new GoogleAuthorizationCodeFlow.Initializer
{
ClientSecrets = new ClientSecrets
{
ClientId = _clientId,
ClientSecret = _clientSecret
},
Scopes = UserAccountCreds.SCOPES,
DataStore = new FileDataStore(@"C:\GoogleDriveViewer\DataStore", true)
});
UserCredential credentials = new UserCredential(flow, "user", token); // HOW DO YOU GET REFRESH TOKEN
DriveService service = new DriveService(new BaseClientService.Initializer()
{
HttpClientInitializer = , // HELP NEEDED HERE
ApplicationName = "Drive API Sample",
});