2016-08-12 11 views
0

サードパーティのサービス(この場合はSoundcloud)に対してASP.NETアプリケーション/ログインを認証できました。使用したいAPIには、ログインプロセス中に提供された認証トークンが必要です。トークンはどこで入手できますか?asp.netでsoundcloud Oauth2トークンを取得

答えて

0

他の誰かが知りたいと思うように答えが見つかった場合、そのトークンはオプションの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; 
関連する問題