windows-8soundcloudwebbroker

SoundCloud in Windows 8 app Web broker


SoundCloud api doesnot allow to login from Windows 8 Javascript Web broker. I was using Windows 8 any service web broker example


Solution

  • I've managed to connect a Windows store app using the WebAuthenticationBroker class, however this was written in C#, but hopefully it can be of assistance:

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

    startUri is the call to the /connect endpoint and endUri is your callback uri.

    You can then process the response and call the /oauth2/token endpoint to get an access 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;
         }
    }
    

    Hopefully you can read this across into JavaScript.

    All the best!