Spotify - 如何/在哪里生成 ENCRYPTION_SECRET?

Posted

技术标签:

【中文标题】Spotify - 如何/在哪里生成 ENCRYPTION_SECRET?【英文标题】:Spotify - How/Where to generate ENCRYPTION_SECRET? 【发布时间】:2019-02-15 00:24:00 【问题描述】:

我正在尝试实现这个插件https://github.com/Festify/cordova-spotify-oauth

https://github.com/Festify/cordova-spotify-oauth/blob/develop/oauth-token-api/spotifyTokenService.js

CLIENT_ID="got from spotify dev account"
CLIENT_SECRET="got from spotify dev account"
CLIENT_CALLBACK_URL="my-app://callback"
ENCRYPTION_SECRET="<Secret used to encrypt the refresh token - please generate>"

在上面的环境变量中,无论我放入 ENCRYPTION_SECRET,它总是抛出错误

TypeError: Bad input string
    at TypeError (native)
    at Decipher.update (crypto.js:146:26)
    at Object.module.exports.decrypt (/user_code/lib/crypto.js:14:21)
    at exports.refreshToken.functions.https.onRequest (/user_code/index.js:104:31)
    at cloudFunction (/user_code/node_modules/firebase-functions/lib/providers/https.js:37:41)
    at /var/tmp/worker/worker.js:689:7
    at /var/tmp/worker/worker.js:673:9
    at _combinedTickCallback (internal/process/next_tick.js:73:7)
    at process._tickDomainCallback (internal/process/next_tick.js:128:9)

我试过了:

ENCRYPTION_SECRET=123 ENCRYPTION_SECRET=cFJLyifeUJUBFWdHzVbykfDmPHtLKLGzViHW9aHGmyTLD8hGXC (只是随机文本) 也在 Spotify Dev Account 中搜索过,没有找到任何生成 ENCRYPTION_SECRET 的选项

提前致谢。

【问题讨论】:

您的问题是错字吗? ENCRYPTION_SECRECT 应该是 ENCRYPTION_SECRET 根据文档,它是 ENCRYPTION_SECRET,在我的代码中也是 ENCRYPTION_SECRET 这只是一个用于加密您的密钥的随机字符串。你在你的 .env 文件中用引号括起来了吗? 不加引号 @AlexMan 因此,您应该编辑您的问题并删除您输入的示例中的错字。 ;o) 【参考方案1】:

加密密钥可以是任何你想要的,它只是一个确保刷新令牌通信安全的密钥。

【讨论】:

以上是关于Spotify - 如何/在哪里生成 ENCRYPTION_SECRET?的主要内容,如果未能解决你的问题,请参考以下文章

如何在 Spotify 中获取 Artist 的城市信息?

如何从 Spotify 播放列表中获取数据

Spotify 插件开放 Spotify

如何获取 Spotify 跟踪 uri?

如何使用 Spotify Web API 获取当前播放/最近播放的歌曲

如何使用我的 spotify api 令牌?