Curl 使用命令行连接到Spotify API

Curl 使用命令行连接到Spotify API,curl,spotify,access-token,Curl,Spotify,Access Token,我希望通过命令行从Spotify API检索信息,例如: curl "https://api.spotify.com/v1/search?type=artist&q=<someartist>" myscript.sh some_artist some_album 我已经在我的Spotify开发者帐户中创建了一个应用程序。有人能告诉我如何在我的搜索请求中传递我的凭据吗?我不想编写应用程序或任何东西。我只想从命令行检索信息 希望有人能帮忙 因此,我花了更多

我希望通过命令行从Spotify API检索信息,例如:

curl "https://api.spotify.com/v1/search?type=artist&q=<someartist>"
myscript.sh some_artist some_album
我已经在我的Spotify开发者帐户中创建了一个应用程序。有人能告诉我如何在我的搜索请求中传递我的凭据吗?我不想编写应用程序或任何东西。我只想从命令行检索信息


希望有人能帮忙

因此,我花了更多的时间在上破译指令,实际上我找到了一个相当简单的解决方案

我想做的是通过搜索特定的相册从Spotify Web API检索Spotify相册URI。因为我不需要刷新访问令牌,也不需要访问用户数据,所以我决定使用客户机凭据授权流()。以下是我所做的:

  • 在位于的仪表板上创建应用程序,并复制客户端ID和客户端机密

  • 使用base64编码客户端ID和客户端机密:

    echo -n <client_id:client_secret> | openssl base64
    

    它将输出相册URI。

    谢谢,我已经看到了该页面,但我无法让它工作。你能帮我找出正确的命令吗?它不仅仅是一个命令,它是一个接收令牌并使用这些令牌来验证你的应用程序的流程“这是如何运作的”这个问题太宽泛了。我建议您尝试一些流,谷歌、youtube等都非常有用,您不是第一个尝试使用Spotify Api的人;)如果你在一些尝试后陷入困境,你的问题,告诉我们你尝试了什么以及它们产生的错误。考虑阅读:我做到了!谢谢你相信我!:)
    curl -X "POST" -H "Authorization: Basic <my_encoded_credentials>" -d grant_type=client_credentials https://accounts.spotify.com/api/token
    
     curl -H "Authorization: Bearer <my_access_token>" "https://api.spotify.com/v1/search?q=<some_artist>&type=artist"
    
    #!/bin/bash
    artist=$1
    album=$2
    creds="<my_encoded_credentials>"
    access_token=$(curl -s -X "POST" -H "Authorization: Basic $creds" -d grant_type=client_credentials https://accounts.spotify.com/api/token | awk -F"\"" '{print $4}')
    result=$(curl -s -H "Authorization: Bearer $access_token" "https://api.spotify.com/v1/search?q=artist:$artist+album:$album&type=album&limit=1" | grep "spotify:album" | awk -F"\"" '{print $4 }')
    
    myscript.sh some_artist some_album