私はAzure AD資格情報で自分のアプリケーションにサインインできます。Azure ADユーザー情報(JWTベアラトークンとASP.NET Core 2 WebApi)
私のフロントエンドで私はXamarin.Formsを使用しています。 バックエンドで私はASP.NET Core 2.0 WebApiを使用しています。
バックエンド:
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseAuthentication();
app.UseMvc();
}
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddAuthentication(o =>
{
o.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
o.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
}).AddJwtBearer(options =>
{
options.Authority = String.Format(Configuration["AzureAd:AadInstance"], Configuration["AzureAD:Tenant"]);
options.Audience = Configuration["AzureAd:Audience"];
});
}
それはかなり簡単です。
私のフロントエンドでは、私の資格情報を記入し、access_tokenを求めています。
{
"token_type": "Bearer",
"scope": "user_impersonation",
"expires_in": "3600",
"ext_expires_in": "0",
"expires_on": "1507104075",
"not_before": "1507100175",
"resource": "my_resource",
"access_token": "my_access_token",
"refresh_token": "my_refresh_token"
}
私はbearer my_access_token
で認証セットでヘッダに埋めていaccess_tokenは。
私のaccess_tokenの情報で自動的にクレームが設定されるため、My Apiは私のすべての情報を知っています。この情報は、Azure ADによって提供されています。 (氏名、名字、姓など)
しかし、この情報はフロントエンドでどのように取得できますか?