无法启动浏览器|访问被拒绝| Google API授权

时间:2018-03-05 06:43:10

标签: wcf

如果用户已登录系统,我们希望在Google云端硬盘上上传文档。如果第一次用户系统将打开一个用于登录凭据的弹出窗口。当我在QA服务器上发布代码时,下面的代码在我的开发环境(localhost)上工作正常但在QA服务器上没有。

仅供参考,我们使用Google API进行授权。

以下是我的代码段:

       Google.Apis.Drive.v3.DriveService service = null;
        try
        {
            UserCredential credential;

            string credPath = AppDomain.CurrentDomain.BaseDirectory;
            credPath = Path.Combine(credPath, ".credentials/drive-dotnet-quickstart.json");
            credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
               new ClientSecrets
               {
                   ClientId = ConfigurationManager.AppSettings["client_id"],
                   ClientSecret = ConfigurationManager.AppSettings["client_secret"],
               },
                    Scopes,
                    "user",
                    CancellationToken.None,
                    new FileDataStore(credPath, true)).Result;

            // Create Drive API service.
            service = new Google.Apis.Drive.v3.DriveService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = credential,
                ApplicationName = ApplicationName,
            });
        }
        catch (Exception ex)
        {
            throw;
        }
        return service;

以下是错误消息: "无法使用\" https://accounts.google.com/o/oauth2/v2/auth?access_type=offline&response_type=code&client_id=123&redirect_uri=http%3A%2F%2Flocalhost%3A54597%2Fauthorize%2F&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive \"启动浏览器授权。

0 个答案:

没有答案