对Spotify Web API的身份验证请求被拒绝 [英] Authentication Request to Spotify Web API Rejected

查看:144
本文介绍了对Spotify Web API的身份验证请求被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将身份验证请求发送到Login到Spotify.

I am trying to send an authentication request to Login to Spotify.

这是通过javascript XMLHttpRequest通过本地主机运行的.但是,我收到的只是一条错误消息,指出:

This is run through local host by a javascript XMLHttpRequest. However all I ever receive is an error message stating:

XMLHttpRequest无法加载 https://accounts.spotify. com/authorize/?q = undefined& type = code& client_id = 9f5 …ope = user-read-private%20user-read-email%20streaming& state = iKX8sdHHEML6BxRy.

XMLHttpRequest cannot load https://accounts.spotify.com/authorize/?q=undefined&type=code&client_id=9f5…ope=user-read-private%20user-read-email%20streaming&state=iKX8sdHHEML6BxRy.

所请求的资源上没有"Access-Control-Allow-Origin"标头.因此,不允许对源本地主机"进行访问."

No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin "localhost" is therefore not allowed access."

我尝试将标头设置为xmlrequest.setRequestHeader("Access-Control-Allow-Origin", "*");,但这不起作用.

I tried setting the header doing xmlrequest.setRequestHeader("Access-Control-Allow-Origin", "*"); however this did not work.

推荐答案

如果我对您的理解正确,那么您正在尝试从用户那里检索授权码.如果是这样,您需要做的就是将用户重定向到上面提供的URL.这将引导用户完成一个流程,在该流程中,用户将授予您的应用程序权限.流程完成后,用户将被重定向到您的重定向回调URL.如果成功,则授权代码将成为查询参数之一,然后将用户重定向回您的服务器.

If I'm understanding you correctly, you're attempting to retrieve an authorization code from the user. If so, what you need to do is to redirect the user to the URL you've given above. This will take the user through a flow where the user grants your application permissions. When the flow is completed, the user is redirected to your redirect callback URL. If successful, the authorization code will be one of the query parameters when then the user is redirected back to your server.

文档:授权代码流

这篇关于对Spotify Web API的身份验证请求被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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