我想從筆記本電腦上的本地HTML頁面訪問Soundcloud。我被卡在主機「callback.html」的部分作爲redirect_uri。我試圖運行該腳本是從的SoundCloud文檔頁面的基本Authenication的JavaScript:redirect_uri以及如何在SoundCloud上託管callback.html?
<script src="http://connect.soundcloud.com/sdk.js"></script>
<script>
// initialize client with app credentials
SC.initialize({
client_id: 'my_client_id',
redirect_uri: 'http://127.0.0.1/Users/Maria/Documents/SoundcloudClient/callback.html'
});
// initiate auth popup
SC.connect(function() {
SC.get('/me', function(me) {
alert('Hello, ' + me.username);
});
});
</script>
這個劇本讓我成爲連接彈出,當我啓動頁面在Chrome和Firefox瀏覽器。 但是,一旦我已經登錄的用戶的SoundCloud,我得到以下錯誤:
Oops! Google Chrome could not connect to 127.0.0.1
如果我改變我的REDIRECT_URI爲localhost我得到同樣的錯誤。
如果我嘗試:
files:///C:/Users/Maria/Documents/SoundcloudThinClient/callback.html
,我收到了類似的錯誤。
我也試過:
ocalhost:3000
和:
localhost:8080
即使我不知道你會在這些端口上偵聽。
所以,基本上,我問我爲callback.html放了什麼路徑才能工作?
我承認我不知道redirct_uri實際上是如何工作的。我看了一下Oauth的頁面,但我不明白它們。我開始認爲我不能簡單地創建一個HTML頁面,粘貼JavaScript,創建一個callback.html文件並完成這項工作,即使SC文檔似乎認爲這是可能的。如果是這樣,我錯過了哪些步驟?
這是一個答案或問題? –