Soundcloud 身份验证/连接 javascript 问题 [英] Soundcloud authentication/connection javascript issue

查看:23
本文介绍了Soundcloud 身份验证/连接 javascript 问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<script src="http://connect.soundcloud.com/sdk.js"></script><script src="http://code.jquery.com/jquery-1.8.2.min.js"></script><脚本>//使用应用程序凭据初始化客户端SC.初始化({client_id: 'bea6b4a2c1108a4cfa99f0d40966108a',redirect_uri: 'http://www.samplewars.com/'});//启动身份验证弹出窗口SC.connect(function() {SC.get('/me', function(me) {alert('你好,' + me.username);});});不安全的 JavaScript 尝试从 URL http://www.samplewars.com/soundcloud/?code=77c9dc160d723a52f67d42a89067848e&state=SoundCloud_Dialog_80886#access_69535-1211-78151464de9a2ec39&scope=未到期.域、协议和端口必须匹配.

我在我的 chrome 控制台中收到此错误,而在 FF 中,它只是不断循环执行允许过程,而没有发出警报.

有趣的是,它工作了一秒钟,然后我去喝了一杯,回来了,它坏了.

它也留在弹出窗口内,而不是关闭回原始窗口编辑 2:它实际上还在应用程序的连接菜单中添加了 soundcloud 内部的权限.只是不吐出警报.

编辑 3:好的,在我添加了一个 onclick 事件以阻止它不断循环遍历 js 之后,它现在可以在 FF 中工作了.所以现在的代码是:

<script src="http://connect.soundcloud.com/sdk.js"></script><脚本>//使用应用程序凭据初始化客户端SC.初始化({client_id: 'bea6b4a2c1108a4cfa99f0d40966108a',redirect_uri: 'http://www.samplewars.com/'});//启动身份验证弹出窗口函数 connectSC(){SC.connect(function() {SC.get('/me', function(me) {alert('你好,' + me.username);});});}<div id="connect_button" onClick="connectSC()">连接到声音云

在 FF 中有效,但在 Chrome 或 IE 中无效.

解决方案

有趣的因素.我发现了这个问题,如果您尝试使用没有 www 的 URL 进行连接.作为前缀,它不起作用.Soundcloud 必须需要它才能构建令牌

<script src="http://connect.soundcloud.com/sdk.js"></script>
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script>
// initialize client with app credentials
SC.initialize({
  client_id: 'bea6b4a2c1108a4cfa99f0d40966108a',
  redirect_uri: 'http://www.samplewars.com/'
});

// initiate auth popup
SC.connect(function() {
  SC.get('/me', function(me) { 
    alert('Hello, ' + me.username); 
  });
});
</script>


Unsafe JavaScript attempt to access frame with URL http://samplewars.com/soundcloud/ from frame with URL http://www.samplewars.com/soundcloud/?code=77c9dc160d723a52f67d42a89067848e&state=SoundCloud_Dialog_80886#access_token=1-26934-195352-78151464de9a2ec39&scope=non-expiring. Domains, protocols and ports must match.

I'm getting this error in my chrome console, and in FF it just keeps looping through the allow process without shooting out the alert.

Funny thing is, it worked for a second, then I went to get a drink, came back, and it was broken.

edit: it also stays inside of the popup as opposed to closing back to the original window edit 2: it ALSO actually adds the permissions inside of soundcloud in the connect menu for the app. Just doesn't spit out the alert.

Edit 3: Okay, it works in FF now after I added an onclick event to stop it from constantly looping through the js. so now the code is:

<script src="http://connect.soundcloud.com/sdk.js"></script>
<script>
// initialize client with app credentials
SC.initialize({
  client_id: 'bea6b4a2c1108a4cfa99f0d40966108a',
  redirect_uri: 'http://www.samplewars.com/'
});

// initiate auth popup
function connectSC(){
SC.connect(function() {
  SC.get('/me', function(me) { 
    alert('Hello, ' + me.username); 
  });
});
}
</script>
<div id="connect_button" onClick="connectSC()">
connect to soundcloud
</div>

Which works in FF, but not in Chrome or IE.

解决方案

Interesting factor. I found the issue, if you try to connect using an URL without www. as the prefix, it won't work. Soundcloud must require it in order to build the token

这篇关于Soundcloud 身份验证/连接 javascript 问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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