Spotify身份验证已取消,索引超出范围

时间:2018-09-25 20:28:54

标签: c# server spotify

我正在使用SpotifyAPI-NET创建一个Spotify应用程序。通过身份验证后,索引超出范围。我不知道为什么会这样,因为它似乎是在API方面,并且异常消息没有帮助,因为它是多线程的。

lp.guidePercent = 0.4f;

服务器运行正常,身份验证也正常,直到我单击“确定”按钮为止。然后,它重定向到带有“ Spotify Auth cancel!”的页面。并且我得到了超出范围异常的索引。

这里是例外:

private static SpotifyWebAPI _spotify;

//...in an async method
WebAPIFactory webApiFactory = new WebAPIFactory(
    Spotify.RedirectURL, //http://localhost:8008/test/
    Spotify.Port, //8000
    Spotify.ClientID,
    Scope.UserReadPrivate,
    TimeSpan.FromSeconds(20)
);

try {
    _spotify = await webApiFactory.GetWebApi(); //exception here
} catch (Exception ex) {
    Console.WriteLine(ex.Message);
}

我尝试了另一种登录方式,但是它似乎也不起作用:

    Unhandled Exception: System.ArgumentOutOfRangeException: Index was out 
of range. Must be non-negative and less than the size of the collection.
Parameter name: index
    at System.Collections.ArrayList.get_Item(Int32 index)

    at System.Collections.Specialized.NameValueCollection.GetKey(Int32 index)

    at System.Web.HttpValueCollection.Get(Int32 index)

    at SpotifyAPI.Web.SimpleHttpServer.<>c__DisplayClass6_1.<HandleGetRequest>b__2(Object o)

    at System.Threading.ThreadHelper.ThreadStart_Context(Object state)

    at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)

    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)

    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)

    at System.Threading.ThreadHelper.ThreadStart(Object obj)

0 个答案:

没有答案