我无法从 Spotify 为我的应用检索访问令牌

I can't retrieve an access token from Spotify for my app

我无法从 Spotify 为我的 Android 应用程序获取访问令牌,因为我可以连接到端点。

我需要我的 Android 应用程序的访问令牌,我尝试了以下操作: 1) Spotify Android 授权库。我找不到他们谈论的 spotify-auth-version.aar。 2) 手动构建 url。这是一个例子:

https://accounts.spotify.com/authorize?
client_id=xxxxxxxxxxxxxxxxxxxxxxxxxxxx&
response_type=code&
redirect_uri=http%3A%2F%2Fmarcoalunno.com.spotify_test%2Fcallback&
scope=playlist-read-private&
state=34fFs29kd09

当我尝试连接时,我遇到了各种可能的错误:"Missing required parameter: client_id"、"INVALID_CLIENT: Invalid redirect URI"、"Page not found",甚至其他我不记得了。我想问题出在 redirect_uri 上。所以,我添加了几个不同的重定向地址并尝试了所有这些,但没有。

这是我在我的应用程序中添加的地址: https://spotify_test.com/callback http://marcoalunno.com/callback http://localhost:8888/callback/ http://marcoalunno.com.spotify_test/callback

及其编码版本: https%3A%2F%2Fspotify_test.com%2Fcallback%0A http%3A%2F%2Fmarcoalunno.com%2Fcallback%0A http%3A%2F%2Flocalhost%3A8888%2Fcallback%2F%0A http%3A%2F%2Fmarcoalunno.com.spotify_test%2Fcallback

我知道很多人在 Whosebug 上询问 "INVALID_CLIENT: Invalid redirect URI",但我找不到决定性的答案,对此我感到非常沮丧。

据我所知,.aar 文件是将此库集成到项目中的旧方法,现在您只需将以下行添加到 build.gradle:

compile 'com.spotify.android:auth:1.1.0'

可以在库 GitHub page.

上找到更多信息和所需的进一步步骤

您是否对服务器上的重定向 URI 进行了处理?我刚刚将 soundtrack://callback 用于我名为 app 的配乐。我想你几乎可以使用任何你喜欢的东西,只要它与你的 Spotify 开发者仪表板和你的 android 应用程序的清单文件中的匹配。

在 Spotify Auth 库的帮助下,与手动方式相比,应该更容易进行身份验证。如果您想采用手动方式,我可以查看 url 构建过程并相应地编辑此答案。

spotify auth示例工程中的相关文件为: