Windows 8应用程序Web代理中的SoundCloud

时间:2013-06-12 07:13:16

标签: windows-8 soundcloud webbroker

SoundCloud api不允许从Windows 8 Javascript Webbroker登录。我在使用Windows 8任何服务Web代理示例

1 个答案:

答案 0 :(得分:1)

我已经设法使用WebAuthenticationBroker类连接Windows商店应用程序,但这是用C#编写的,但希望它可以提供帮助:

WebAuthenticationResult war = await WebAuthenticationBroker.AuthenticateAsync(WebAuthenticationOptions.None, startUri, endUri);

startUri是对/ connect端点的调用,endUri是你的回调uri。

然后,您可以处理响应并调用/ oauth2 / token端点以获取访问令牌:

switch (war.ResponseStatus)
{
    case WebAuthenticationStatus.Success:
    {
        string response = war.ResponseData;
        string[] responseSplit = response.Split('=');
        string authCode = responseSplit[1];
        // call /oauth2/token with the authorisation code...
        break;
     }
     case WebAuthenticationStatus.UserCancel:
     {
         OutputMessage(war.ResponseStatus.ToString());
         break;
     }
     case WebAuthenticationStatus.ErrorHttp:
     {
         OutputMessage(war.ResponseStatus.ToString());
         break;
     }
}

希望您可以将其读入JavaScript。

一切顺利!