NHSDigital.ApiPlatform.Sdk.AspNetCore
0.2.0.1
dotnet add package NHSDigital.ApiPlatform.Sdk.AspNetCore --version 0.2.0.1
NuGet\Install-Package NHSDigital.ApiPlatform.Sdk.AspNetCore -Version 0.2.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="NHSDigital.ApiPlatform.Sdk.AspNetCore" Version="0.2.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NHSDigital.ApiPlatform.Sdk.AspNetCore" Version="0.2.0.1" />
<PackageReference Include="NHSDigital.ApiPlatform.Sdk.AspNetCore" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add NHSDigital.ApiPlatform.Sdk.AspNetCore --version 0.2.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: NHSDigital.ApiPlatform.Sdk.AspNetCore, 0.2.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package NHSDigital.ApiPlatform.Sdk.AspNetCore@0.2.0.1
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=NHSDigital.ApiPlatform.Sdk.AspNetCore&version=0.2.0.1
#tool nuget:?package=NHSDigital.ApiPlatform.Sdk.AspNetCore&version=0.2.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
NHSDigital.ApiPlatform.Sdk.AspNetCore
Overview
NHSDigital.ApiPlatform.Sdk.AspNetCore is the ASP.NET Core adapter
for:
NHSDigital.ApiPlatform.Sdk
It provides:
- Session-based token/state storage
- Cookie-based token/state storage (BFF-style)
- DI registration helpers
- Seamless integration into ASP.NET Core applications
Installation
dotnet add package NHSDigital.ApiPlatform.Sdk
dotnet add package NHSDigital.ApiPlatform.Sdk.AspNetCore
Configuration (appsettings.json)
{
"ApiPlatform": {
"CareIdentity": {
"ClientId": "...",
"ClientSecret": "...",
"RedirectUri": "...",
"AuthEndpoint": "...",
"TokenEndpoint": "...",
"UserInfoEndpoint": "...",
"AcrValues": "aal3"
},
"PersonalDemographicsService": {
"BaseUrl": "..."
}
}
}
Registration
Session Mode (Recommended to Start)
builder.Services.AddDistributedMemoryCache();
builder.Services.AddSession();
builder.Services.AddApiPlatformSdkAspNetCore(
builder.Configuration.GetSection("ApiPlatform")
.Get<ApiPlatformConfigurations>(),
storageMode: ApiPlatformAspNetStorageMode.Session);
app.UseSession();
Cookie Mode (BFF-Style)
builder.Services.AddApiPlatformSdkAspNetCore(
builder.Configuration.GetSection("ApiPlatform")
.Get<ApiPlatformConfigurations>(),
storageMode: ApiPlatformAspNetStorageMode.Cookies);
Cookies are: - HttpOnly - Secure (when HTTPS) - SameSite=Lax
Example Auth Controller
[ApiController]
[Route("auth")]
public sealed class AuthController : ControllerBase
{
private readonly IApiPlatformClient api;
public AuthController(IApiPlatformClient api) => this.api = api;
[HttpGet("login")]
public IActionResult Login()
{
string url = this.api.CareIdentityServices.Login();
return Redirect(url);
}
[HttpGet("callback")]
public IActionResult Callback(string code, string state)
{
this.api.CareIdentityServices.Callback(code, state);
return Redirect("/");
}
[HttpPost("logout")]
public IActionResult Logout()
{
this.api.CareIdentityServices.Logout();
return Redirect("/");
}
}
Example PDS Controller
[ApiController]
[Route("pds")]
public sealed class PdsController : ControllerBase
{
private readonly IApiPlatformClient api;
public PdsController(IApiPlatformClient api) => this.api = api;
[HttpGet("patients")]
public async Task<IActionResult> Search(string family)
{
string result = await this.api
.PersonalDemographicsServices
.SearchPatientsAsync(family);
return Content(result, "application/fhir+json");
}
}
Refresh Token Renewal
All calls automatically use:
GetAccessToken()
If expired, the SDK:
- Uses refresh token
- Calls token endpoint
- Stores new tokens
- Continues execution
No extra developer code required.
Requirements
Session Mode
AddSession()UseSession()
Cookie Mode
- HTTPS recommended for production
© North East London ICB
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- NHSDigital.ApiPlatform.Sdk (>= 0.2.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.2.0.1 | 71 | 3/23/2026 |
Initial release of the NHS Digital API Platform Client.