使用GoogleAuthorizationCodeFlow进行Google云端硬盘服务初始化(如何获取刷新令牌?)

时间:2016-03-03 02:12:34

标签: asp.net-mvc c#-4.0 google-drive-api

我有一个在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",
                    });

0 个答案:

没有答案