整合Google云端硬盘时,Google同意屏幕未显示

时间:2015-09-13 04:46:05

标签: c# google-oauth2

我无法在ASP.NET网络应用程序中集成G​​oogle云端硬盘。它没有显示同意屏幕,用户可以输入他/她的Google凭据来授权我的应用程序。

以下是我的代码:

String CLIENT_ID = "XXXXXX";
String CLIENT_SECRET = "XXXXXX";
String APP_USER_AGENT = "<Application - Name>";
string[] scopes = new string[] { DriveService.Scope.Drive };
DriveService service=null;

try
{
    var dbDataStore = new DatabaseDataStore("<DBServer>", "<DBUser>", "<Pwd>", "<DataBase>");
    UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(new ClientSecrets { ClientId = CLIENT_ID, ClientSecret = CLIENT_SECRET },
            scopes, Convert.ToString(Session["UserId"]), CancellationToken.None, dbDataStore).Result;

    service = new DriveService(new BaseClientService.Initializer()
    {
        HttpClientInitializer = credential,
        ApplicationName = APP_USER_AGENT,
    });
}
catch (Exception ex)
{
}

1 个答案:

答案 0 :(得分:0)