- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
这是 Spotify API 的文档(我使用的是隐式授权流程):https://beta.developer.spotify.com/documentation/general/guides/authorization-guide/#implicit-grant-flow
我正在尝试在 Google 表格中编写脚本。我专注于基本设置,但似乎无法让访问 token 正常工作。
SOLVED:
I'm currently receiving the following error (it seems like my parameters for my fetch method aren't set properly):
"error":"unsupported_grant_type","error_description":"grant_type must be client_credentials, authorization_code or refresh_token"
SOLUTION:
The grant_type must be listed as a payload according to the Google Scripts method UrlFetchApp.fetch (see updated code below)
SOLVED:
As you can see below I'm using the 'get' method when trying to get the token (despite the documentation specifying 'post') because the post method consistently returns a 405 error. I think this is the step I'm screwing up on. I'm assuming that I'm not supposed to be using the csrf_token as the access token.
SOLUTION:
https://accounts.spotify.com/token should have been https://accounts.spotify.com/api/token
var fetchParams = {
'method':'post',
'payload':{'grant_type':'client_credentials'},
'headers':{'Authorization':authorization},
'muteHttpExceptions':true
}
var replaceResponse = UrlFetchApp.fetch('https://accounts.spotify.com/api/token', fetchParams);
var regExp = /access_token(.*?):/;
var contentText = replaceResponse.getContentText();
var access_token = contentText.slice(contentText.search('access_token')+15,contentText.search(',')-1);
var requestOptions = {
'headers':{'Authorization':'Bearer '+access_token},
'muteHttpExceptions':true
}
var finalResponse = UrlFetchApp.fetch('https://api.spotify.com/v1/tracks/4dhARBZ8YLvm8oRDnCIeXr', requestOptions);
最佳答案
我按照 curl -X "POST" -H "Authorization: Basic ZjM4ZjAw...WY0MzE=" -d grant_type=client_credentials https://accounts.spotify.com/api/token
修改了用于检索访问 token 的脚本的文件。你能试试这个修改过的脚本吗?
var authorization = "Basic "+ Utilities.base64Encode('<client_id>:<client_secret>');
var fetchParams = {
method: 'post', // Modified
payload: {'grant_type': 'client_credentials'}, // Modified
headers: {'Authorization': authorization},
muteHttpExceptions: true
}
var replaceResponse = UrlFetchApp.fetch("https://accounts.spotify.com/api/token", fetchParams); // Modified
Logger.log(replaceResponse.getContentText())
关于javascript - Spotify API - 在 Google Apps 脚本中检索有效的访问 token ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50459496/
据我所知,不可能开发一个Web应用程序(在spotify.com之外)提供播放Spotify歌曲的自定义Web播放器,对吗?唯一的选择似乎仍然是 Spotify 播放按钮,但功能非常有限。 不过,我刚
我想从 Spotify 应用程序中运行 Spotify 搜索(以查找艺术家的轨道,我没有该艺术家的 Spotify URI,只有名称)。 我尚未在 App API 中找到用于运行搜索的功能。另一种方法
所以我看了一下spotify web api,它显然允许你播放歌曲的预览,但我想知道是否有任何方法可以播放完整的spotify歌曲而无需打开官方的spotify网络播放器或桌面应用程序。 谢谢 最佳答
我在使用 Spotify API 时发现了一个奇怪的行为。有些轨道有两个不同的 ID,即使轨道在同一张专辑中也是如此。 例子: https://api.spotify.com/v1/tracks/0Y
我只想能够通过发送/接收 http 请求(一个独立的网络应用程序,而不是 Spotify 应用程序和桌面客户端)来创建一个播放列表。我翻遍了文档,找不到明确的解决方案。有人可以指出我正确的方向吗?提前
如何将轨道添加到 Spotify 应用程序中的当前播放队列? 最佳答案 您需要创建一个未命名的播放列表来创建您自己的播放队列。 function playTracks(tracks, index) {
有没有像 Spotify 远程控制 API 这样的东西?我想编写一个应用程序,让用户控制 Spotify 桌面客户端(播放、暂停、音量、播放列表等),但我似乎无法在任何地方找到任何文档。 那里有 iO
在 Google 上找不到关于该主题的任何内容,所以我在这里问。 我有一个基于网络的 Spotify 播放器(不像官方播放器)的想法,我想知道是否可以让客户端(用户)从 Spotify 而不是我的服务
我是 playmoss 的开发人员,用户可以在其中创建具有不同音乐服务的播放列表。 我们计划以类似于 bop.fm 的方式将 Spotify 支持添加到我们的播放列表中。 语境 以这个播放列表为例(其
我正在尝试创建一个 Spotify 应用程序,但在登录时收到一条奇怪的错误消息:*19:28:57.916 I [offline_authorizer.cpp:289]无法离线登录:没有这样的用户 i
我正在尝试开发一个应用程序,在该应用程序中我需要解决一个查询,以按城市位置获取艺术家的追随者和听众的数量。 提前致谢, 笔记: 我已经检查过可以通过使用搜索方法 spotify.search(q="A
我使用 Spotify 来满足我所有的音乐需求,并且想知道是否有某种方法可以编写一个应用程序,让我可以从 Spotify 访问音乐并放慢歌曲速度并循环播放部分歌曲。我是一名音乐家,像这样的东西会有助于
关闭。这个问题需要更多focused .它目前不接受答案。 想改进这个问题吗? 更新问题,使其只关注一个问题 editing this post . 关闭 6 年前。 Improve this qu
如何使用 Spotify API 在 Spotify 上获得“全局”热门轨道列表?例如,我的意思是现在 Spotify 上最流行的 20 首歌曲的列表(对于任何艺术家/国家/地区) 我已经在谷歌上搜索
我在 Raspberry Pi 上使用 libspotify 12.1.103.gd51f6226 Release Linux-armv6-bcm2708hardfp,我认为按照自述文件中的说明一切正
我正在尝试获取有关 Spotify iOS 应用程序中当前正在播放的歌曲的信息。场景如下:打开Spotify iOS应用程序,开始播放歌曲。将应用程序置于后台并打开我的 iOS 应用程序。有什么办法可
请告知如何在使用 Spotify Web API“https://accounts.spotify.com/api/token”获取数据时增加 token 到期时间 最佳答案 访问 token 在一小
是否可以获得歌曲的播放次数(对于当前用户)?我只找到Toplist和 Track类,但都没有告诉我用户听歌曲的频率。 最佳答案 据我所知,目前无法检索该数据。 关于spotify - 从 Spotif
我想使用 spotify api 来创建一个 webapp。在不详细介绍该项目的情况下,我想弄清楚它是否违反条款和条件。 阅读条款和条件后,我在“不要做的事情”下阅读了这一行:“聚合元数据以创建数据库
在浏览了今天发布的 Spotify Web API 文档后,似乎没有办法播放完整长度的歌曲,即使在授权之后也是如此。 API 似乎只支持 30 秒的歌曲预览。 是否有用于 javascript 的 S
我是一名优秀的程序员,十分优秀!