我正在构建一个需要Spotify来使用ImplicitGrantAuth
对用户进行身份验证的应用程序。我已经在Spotify的开发站上设置了我的应用程序并且有一个ClientID
。我在这个应用程序中使用JohnnyCrazy/SpotifyAPI-NET
。
代码段:
static ImplicitGrantAuth auth;
static void Main(string[] args)
{
//Create the auth object
auth = new ImplicitGrantAuth()
{
//Your client Id
ClientId = "XXXXXXXXXXXXXXXXXX", // example only
//Set this to localhost if you want to use the built-in HTTP Server
RedirectUri = "http://localhost",
//How many permissions we need?
Scope = Scope.UserReadPrivate,
};
//Start the internal http server
auth.StartHttpServer();
//When we got our response
auth.OnResponseReceivedEvent += auth_OnResponseReceivedEvent; // <-- Error here!
//Start
auth.DoAuth();
}
static void auth_OnResponseReceivedEvent(Token token, string state, string error)
{
//stop the http server
auth.StopHttpServer();
var spotify = new SpotifyWebAPI()
{
TokenType = token.TokenType,
AccessToken = token.AccessToken
};
//We can now make calls with the token object
}
编译错误:
没有过载&#39; auth_OnResponseReceivedEvent&#39;匹配委托&#39; SpotifyAPI.Web.Auth.ImplicitGrantAuth.OnResponseReceived&#39;
我不确定我是否忽略了一些非常简单的东西,或者我是否需要特别添加一些东西。我对使用事件处理程序也很陌生。
答案 0 :(得分:1)
auth_OnResponseReceivedEvent
方法中的参数太多了。 string state
委托中没有OnResponseReceived
参数:
public delegate void OnResponseReceived(Token token, String error);
public event OnResponseReceived OnResponseReceivedEvent;