在 OAuth 身份验证流程成功后,我正在尝试从 Google API 读取实际的 JSON 响应。我已阅读 MS Docs ( https://docs.microsoft.com/en-us/aspnet/core/security/authentication/social/additional-claims?view=aspnetcore-5.0#establish-the-authentication-scope ) 其中他们使用 options.ClaimActions.MapJsonKey 将每个键映射到一个声明。但是我不想添加声明,我只想读取所有返回的 JSON 键和值。
.AddGoogle(options => {
options.ClientId = _conf["MyClientId"];
options.ClientSecret = _conf["MySecret"];
options.Events.OnCreatingTicket = ctx => {
// How do I read the JSON returned, via ctx object? I have tried ctx.Response.Body, but didn't get much further.
return Task.CompletedTask;
};