【问题标题】:Flutter Firebase Twitter Auth throwing errorFlutter Firebase Twitter Auth 抛出错误
【发布时间】:2021-12-30 14:13:15
【问题描述】:

我正在尝试将 Twitter 身份验证合并到我的 Flutter 应用程序中。我正在关注 FlutterFire 文档,但出现错误。我想知道是我的问题还是 Twitter 登录插件有问题。这是我的代码:

  Future<UserCredential> signInWithTwitter() async {
    // Create a TwitterLogin instance
    final twitterLogin = new TwitterLogin(
        apiKey: '<1qOvE68aiVbk4URSARlfm0758>',
        apiSecretKey: ' <wQHWRYBweiV5DvEecSUTeSbnT6uwB6080D4vz6WDyY1geT8Paz>',
        redirectURI: '<twitter-firebase-auth>://');

    // Trigger the sign-in flow
    final authResult = twitterLogin.login();

    // Create a credential from the access token
    final twitterAuthCredential = TwitterAuthProvider.credential(
      accessToken: authResult.authToken!,
      secret: authResult.authTokenSecret!,
    );

    // Once signed in, return the UserCredential
    return await FirebaseAuth.instance
        .signInWithCredential(twitterAuthCredential);
  }

我收到以下错误:

The getter 'authToken' isn't defined for the type 'Future<AuthResult>'.
Try importing the library that defines 'authToken', correcting the name to the name of an existing getter, or defining a getter or field named 'authToken'.

【问题讨论】:

标签: firebase flutter dart firebase-authentication


【解决方案1】:

你应该这样做。

final authResult = await twitterLogin.login();

【讨论】:

  • 正如目前所写,您的答案尚不清楚。请edit 添加其他详细信息,以帮助其他人了解这如何解决所提出的问题。你可以找到更多关于如何写好答案的信息in the help center
猜你喜欢
  • 2021-04-15
  • 2020-01-31
  • 2019-10-01
  • 2022-11-24
  • 1970-01-01
  • 2019-05-25
  • 2017-10-13
  • 2019-12-17
  • 2015-01-10
相关资源
最近更新 更多