【问题标题】:Flutter Spotify Api AuthenticationFlutter Spotify API 身份验证
【发布时间】:2020-06-18 14:37:12
【问题描述】:

我需要在使用 Spotify api 的 Flutter 应用中对用户进行身份验证。 我使用 flutter_web_auth 打开 WebView 并让用户在那里登录。 我无法让它返回应用程序。

在 Spotify 仪表板中,我将回调 Uri 设置为:https://spotifydata.com/callback

      final callbackUrl = "https://spotifydata.com/callback";

      void _authenticateSpotfy() async {
        final url = Uri.https('accounts.spotify.com', '/authorize', {
        'response_type': 'code',
        'client_id': clientID,
        'redirect_uri': 'https://spotifydata.com/callback:/',
        'scope': 'user-read-private user-read-email',
    });


    final result = await FlutterWebAuth.authenticate(
        url: url.toString(), callbackUrlScheme: callbackUrl);
  }

AndroidManifest.xml

<activity android:name="com.linusu.flutter_web_auth.CallbackActivity" >
    <intent-filter android:label="flutter_web_auth">
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="https://spotifydata.com/callback" />
    </intent-filter>
</activity>

我在 Stack 上尝试过其他答案,但它们似乎不起作用。

【问题讨论】:

  • 这个冒号有什么问题吗? 'https://spotifydata.com/callback:/' &lt;- :
  • 是否能够找到任何解决方案?我有同样的问题,但找不到任何东西
  • 大哥,spotify_sdk设置成功了吗?

标签: android flutter spotify


【解决方案1】:

Spotify's API docs 中所述,身份验证会在请求成功时将用户重定向到定义的redirect_uri。尝试登录https://spotifydata.com/,它的redirect_uri 设置为redirect_uri=https%3A%2F%2Fspotifydata.com%2Fsongdata。确保定义的 redirect_uri 与 Manifest 文件中配置的回调方案匹配,因为这使应用能够通过 intent-filter 处理重定向 URL。

【讨论】:

    猜你喜欢
    • 2020-07-05
    • 2014-10-30
    • 2022-08-04
    • 2015-02-17
    • 1970-01-01
    • 2022-11-23
    • 2019-12-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多