使用 asp.net 获取 soundcloud Oauth2 令牌

Get soundcloud Oauth2 token with asp.net

我已成功授权我的 ASP.NET application/login 针对第三方服务(在本例中为 Soundcloud)。我要使用的 API 需要在登录过程中提供的授权令牌。我在哪里可以获得令牌?

我找到了答案,以防其他人想知道,可以通过使用选项中的提供商 属性 获得令牌。在这种情况下,我使用令牌设置声明,然后我可以在 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;