2

WebAuthenticationBroker (Microsoft の WinRT サインオン ライブラリ) を使用するには、プロトコルを ms-app:// に設定する必要があります。これは、Web ブラウザーから呼び出したときに正常に動作します。

WinRT アプリ内で WebAuthenticationBroker を介して呼び出すと、プロトコル エラー (422) が発生します。

誰もこれを成功させましたか?

いくつかのサンプルコードは非常に便利です:)

これが私たちのコードです: (私たちのキーはもちろん ---------- に置き換えられます)

        String URL = "https://soundcloud.com/connect?client_id=" + Uri.EscapeDataString("-----------------------------") +
            "&redirect_uri=" + Uri.EscapeDataString("ms-app://rewritez") +
            "&response_type=code&scope=" + Uri.EscapeDataString("non-expiring");


        string url = URL;

        Uri startUri = new Uri(url);
        Uri endUri = new Uri("https://api.soundcloud.com/oauth2/token?");

        try
        {
            WebAuthenticationResult webAuthenticationResult =
                await WebAuthenticationBroker.AuthenticateAsync(WebAuthenticationOptions.UseTitle, startUri, endUri);

            if (webAuthenticationResult.ResponseStatus == WebAuthenticationStatus.Success)
            {
                string token = webAuthenticationResult.ResponseData;
                // now you have the token
            }
            else if (webAuthenticationResult.ResponseStatus == WebAuthenticationStatus.ErrorHttp)
            {
                // do something when the request failed
            }
            else
            {
                // do something when an unknown error occurred
            }
        }
        catch (Exception ex)
        {
            int i = 43; // statement here just so we can set a breakpoint for debuggin
            // do something when an exception occurred
        }
4

0 に答える 0