2012-05-17 3 views
0

OAuth 인증을 Spotify 앱 내부에서 수행하려고합니다. 기본적으로 window.open이 차단되어 있으며이를 해결할 방법이 있는지 확실하지 않습니다. 그래서, 나는 그것을 처리하는 가장 좋은 방법이 무엇인지 궁금 해서요. 다음을 수행 할 수 있기를 원합니다. 1) 사용자를 인증 링크 으로 리디렉션합니다. 2) 인증이 완료되면 반환 URL을 처리하고 액세스 토큰을 추출하도록 알림을 받고 싶습니다.Spotify 앱 내의 OAuth

몇 가지 옵션, 나는 고려하고 : 1) IFrame2) $.ajax() -- problem is, this doesn't seem to load all javascript/css files from the auth url properly.

어떤 제안?

답변

0

나는 auth.showAuthenticationDialog() API가 당신이 옳은 것이라고 생각합니다. 주어진 URL을 보여주는 대화 상자가 뜨면 리턴 URL이 호출 될 때 매개 변수를 돌려줍니다. 문서 here.

var sp = getSpotifyApi(1); 
var auth = sp.require('sp://import/scripts/api/auth'); 

auth.showAuthenticationDialog('http://www.last.fm/api/auth/?api_key=LAST_FM_API_KEY&cb=sp://my_app_name', 'sp://my_app_name', { 

    onSuccess : function(response) { 
     // Response will be something like 'sp://my_app_name?token=xxxxxxx' 
     console.log("Success! Here's the response URL: " + response); 
    }, 

    onFailure : function(error) { 
     console.log("Authentication failed with error: " + error); 
    }, 

    onComplete : function() { } 
}); 
+0

브릴리언트! 감사합니다! – OneDeveloper

관련 문제