【发布时间】:2015-12-31 18:07:28
【问题描述】:
我正在构建一个需要 Spotify 使用 ImplicitGrantAuth 对用户进行身份验证的应用程序。我已经在 Spotify 的开发人员上设置了我的应用程序,并且有一个 ClientID。我正在为这个应用程序使用JohnnyCrazy/SpotifyAPI-NET。
可以找到隐式授权认证的 API 文档 here.
可以找到 Spotify 的 Implicit Grant Flow 文档 here.
可以找到
ImplicitGrantAuth的原始类 here。
代码 sn-p:
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
}
编译错误:
“auth_OnResponseReceivedEvent”没有过载匹配委托“SpotifyAPI.Web.Auth.ImplicitGrantAuth.OnResponseReceived”
我不确定我是否忽略了一些非常简单的东西,或者我是否需要特别添加一些东西。我对使用事件处理程序也很陌生。
【问题讨论】:
标签: c# api authentication spotify