我有一个包含React组件的ExpressJs服务器。服务器应该处理来自外部的请求,当当前不播放时,一个请求应该播放Spotify API中的歌曲。
app.post("/play", (req, res) => {
try {
// requesting to play uses query params
id = req.query.id;
currPlayingID = 0;
// get the currently playing song from the SPotify API
axios({
url:
我需要从Spotify API获得数据,然后将响应发送到前端。为了避免CORS问题,并对Spotify隐藏密钥和秘密,我想使用Lambda进行API调用,然后返回响应。更准确地说,我的申请是:
1. FrontEnd > API Gateway
2. API Gateway > Lambda
3. Lambda > Spotify API (request their API to get token)
4. Spotify API > Lambda (token in the response)
5. Lambda > API Gateway
6. API Ga
我正在创建一个node.js应用程序,它将每天更新播放列表(由我拥有凭据的帐户所有)。根据Spotify文档,要向播放列表()添加曲目,必须使用oauth2提供授权。
我正在努力寻找一种完全没有重定向/等的服务器端的方法。似乎如果我可以得到一个刷新令牌,我就可以直接使用它?
我一直在研究spotify web api node module ()、oauth.io和spotify api。
任何想法都将不胜感激!只有一个帐户必须进行身份验证,因此它可能是硬编码的,至少现在是这样。
我试图设置一个简单的快捷方式,将当前播放的Spotify曲目添加到spotify播放列表中,以记录我在流中听到的歌曲。
我在用applescript做这个。
到目前为止,我发现有些Spotify API应该能满足我的需求,但我在最后一步失败了。
更确切地说,由于我想修改私有播放列表,这个api (1):需要一个授权令牌。此令牌可以手动检索,到目前为止,此Applescript正在工作:
-- Main
set userID to "XXXXX"
-- my real userID can be retrieved with https://developer.spotify.
当我试图从Spotify API调用获得json响应时,我得到了以下错误:
XMLHttpRequest cannot load https://api.spotify.com/v1/search?query=eminem&offset=0&limit=20&type=artist&market=US. Request header field Access-Token is not allowed by Access-Control-Allow-Headers in preflight response.
我已经注册了我的应用程序,并使用这里的代码(授权代码)
useEffect调用列表的主表数据,如。国家和地点。我使用的是空的依赖列表,这样它只会在挂载后加载。但是错误显示清理没有正确完成,从而导致内存泄漏。 这是我在控制台中看到的错误。 Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in a use