Spotify API 非法 redirect_uri [英] Spotify API Illegal redirect_uri

查看:29
本文介绍了Spotify API 非法 redirect_uri的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试学习 Spotify 开发人员 API 教程,但是当我尝试访问用户登录页面时出现此错误.我已经三重检查代码中的 URI 是否与 MyApplications 页面上的 URI 匹配,但它仍然无法工作.这是脚本,

I'm trying to progress through the Spotify developer API tutorial but when I try to access the user login page I get this error. I've triple checked that the URI in the code matches the one on MyApplications page but it still won't work. Here's the script,

var express = require('express'); // Express web server framework
var request = require('request'); // "Request" library
var querystring = require('querystring');
var cookieParser = require('cookie-parser');

var client_id = id;
var client_secret = secret;
var redirect_uri = "http://localhost:8888/callback";

错误代码和 MyApplications 页面的图片

我不确定我做错了什么,但我已经研究了好几个小时了,有人可以帮忙吗?

I'm not sure what I'm doing wrong but I've been going over it for hours now, can someone help?

推荐答案

您需要重定向 URI 完全相同.您在仪表板中注册的 URI 是 http://localhost:8888/callback/ 带有尾部斜杠.您在代码中使用的版本没有尾部斜杠.只需将您的 redirect_uri 更改为:

You need your redirect URIs to be exactly the same. The URI you have registered in the Dashboard is http://localhost:8888/callback/ with a trailing slash. The version you use in your code does not have the trailing slash. Just change your redirect_uri to be:

var redirect_uri = "http://localhost:8888/callback/";

您可以使用我制作的这个示例授权 URL 验证这是否有效:https://accounts.spotify.com/en/authorize?client_id=df5c5a57b94a4817ae3ac4760c701983&redirect_uri=http:%2F%2Flocalhost:8888%2Fcallback%2F&scope=streaming%20user-read-birthdate%20user-read-birth-modate%20user-read-user-private&redirect_uri=http:%2F%2Flocalhost:8888%2Fcallback%2Fresponse_type=token&show_dialog=true

You can verify that this works with this example authorize URL I made: https://accounts.spotify.com/en/authorize?client_id=df5c5a57b94a4817ae3ac4760c701983&redirect_uri=http:%2F%2Flocalhost:8888%2Fcallback%2F&scope=streaming%20user-read-birthdate%20user-read-private%20user-modify-playback-state&response_type=token&show_dialog=true

这篇关于Spotify API 非法 redirect_uri的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆