Web 谷歌认证和Dart 2

Web 谷歌认证和Dart 2,web,dart,google-oauth,google-authentication,Web,Dart,Google Oauth,Google Authentication,我正在尝试创建一个使用GoogleAPI的webapp,需要使用GoogleAuthAPI对用户进行身份验证。所以我在 并试图运行它。我使用webstorm和dart 2.0.0-dev.68.0。该网页可以调用,但代码从未在主功能中运行到authorizedClient的那部分,也没有给我提供可以登录到google services的弹出窗口 我已经禁用了PopupLocker,当它试图显示时,我也知道被阻止的弹出窗口。这类事情不会发生 同时,我重写了这个示例,使用wait/async代替F

我正在尝试创建一个使用GoogleAPI的webapp,需要使用GoogleAuthAPI对用户进行身份验证。所以我在

并试图运行它。我使用webstorm和dart 2.0.0-dev.68.0。该网页可以调用,但代码从未在主功能中运行到authorizedClient的那部分,也没有给我提供可以登录到google services的弹出窗口

我已经禁用了PopupLocker,当它试图显示时,我也知道被阻止的弹出窗口。这类事情不会发生

同时,我重写了这个示例,使用wait/async代替Future,以便更好地了解它在哪里停止工作。代码如下所示:

Future<auth.AutoRefreshingAuthClient> authorizedClient(ButtonElement loginButton, auth.ClientId id, scopes)
async {
  loginButton.text = "lets go!";

  auth.BrowserOAuth2Flow flow = await auth.createImplicitBrowserFlow(id, scopes);
  loginButton.text = "i am flowing";
  auth.AutoRefreshingAuthClient client;
  try
  {
    loginButton.text = "give it a try...";
    client = await flow.clientViaUserConsent(immediate: true);
    loginButton.text = "i tried it!";
  }
  catch (e)
  {
    loginButton.text = "i failed so bad!";
    client = null;
  }

  if (client == null)
  {
    loginButton.text = "no client available";
    {
      loginButton.text = "give me rights!";
      client = await flow.clientViaUserConsent(immediate: false);
    }
  }

  return client;
}
Future authorizedClient(按钮元素登录按钮,auth.ClientId,作用域)
异步的{
loginButton.text=“放手!”;
auth.browserveauth2flow=等待auth.createImplicitBrowserFlow(id,作用域);
loginButton.text=“我在流动”;
auth.AutoRefreshingAuthClient;
尝试
{
loginButton.text=“尝试一下…”;
client=wait flow.clientvia用户同意(立即:true);
loginButton.text=“我试过了!”;
}
捕获(e)
{
loginButton.text=“我失败得太厉害了!”;
client=null;
}
if(客户端==null)
{
loginButton.text=“没有可用的客户端”;
{
loginButton.text=“给我权限!”;
client=wait flow.clientvia用户同意(立即:false);
}
}
返回客户;
}
当我运行这段代码时,loginButton上的显示变为“尝试一下…”,然后什么也没有发生。似乎函数flow.clientviauserapprovance一直在运行,甚至没有创建错误,因此没有显示文本“i failed so bad!”


dart 2中对google_auth的支持是否已中断,或者github上的示例是否与当前dart开发不同步?

同时,我设法使其运行。主要问题是WebStorm开发的Web服务器在启动时总是获得一个随机端口。对于google身份验证,web项目的api控制台中必须有链接到调用域(包括端口)的url。端口不能是通配符

现在,我自己启动开发服务器时总是使用相同的端口,我也将该端口放在谷歌api控制台中授权的javascript源代码中。完成此操作后,登录成功