我已成功设法授权我的ASP.NET应用程序/登录第三方服务(在本例中为Soundcloud)。 我想要使用的API需要在登录过程中提供的授权令牌。 我在哪里可以获得令牌?
I have successfully managed to authorise my ASP.NET application/login against a 3rd party service (in this case Soundcloud). The API I want to use requires the authorisation token that was provided during the login process. Where can I get the token?
最满意答案
我找到了答案以防其他人想知道,通过使用选项中的Provider属性可以获得令牌。 在这种情况下,我使用令牌设置了一个声明,然后我可以在SignInManager.AuthenticationManager.GetExternalLoginInfo()的claim属性中访问它。
app.UseSoundCloudAuthentication(new SoundCloudAuthenticationOptions { ClientId = "CLIENT_ID", ClientSecret = "CLIENT_SECRET", Provider = new Owin.Security.Providers.SoundCloud.Provider.SoundCloudAuthenticationProvider { OnAuthenticated = async context => { context.Identity.AddClaim(new Claim("AccessToken", context.AccessToken)); await Task.Yield(); } } }); var accessToken = info.ExternalIdentity.Claims.Single(x => x.Type == "AccessToken").Value;I found the answer in case anyone else wants to know, the token is available by using the Provider property in the options. In this case, I set a claim with the token, which I can then access in the claims property of SignInManager.AuthenticationManager.GetExternalLoginInfo()
app.UseSoundCloudAuthentication(new SoundCloudAuthenticationOptions { ClientId = "CLIENT_ID", ClientSecret = "CLIENT_SECRET", Provider = new Owin.Security.Providers.SoundCloud.Provider.SoundCloudAuthenticationProvider { OnAuthenticated = async context => { context.Identity.AddClaim(new Claim("AccessToken", context.AccessToken)); await Task.Yield(); } } }); var accessToken = info.ExternalIdentity.Claims.Single(x => x.Type == "AccessToken").Value;更多推荐
发布评论