Hi.
I was capable of finishing open-access and API key authentication tutorials (for both I got the following json response from the Hello World API):
{
“message”: “Hello Application!”
}
I need your help in order to complete Application-restricted RESTful APIs - signed JWT authentication tutorial.
I followed the tutorial: Signed JWT authentication - C# tutorial - NHS Digital
-
Link Application-restricted RESTful APIs - signed JWT authentication - NHS Digital teaches how to generate a key pair ( Generate your own private/public key pair - for production or test environments)
-
I upload my public key (the json file generated by the bash shell) to my developer account.
-
I downloaded Git examples and opened application-restricted-signed-jwt-tutorials C# project.
-
I changed the code here:
4.1. var tokenUrl = “https:// sandbox .api.service.nhs.uk/oauth2/token” (without the spaces);
4.2. var privateKeyFile = “PRIVATE_KEY_MY_PC_FULL_PATH_AND_NAME” (Here, I changed the file name from MY_KID.pem to MY_KID.key because of the JwtHandler method);
4.3. var clientId = “MY_API_KEY”;
4.4. var kid = “MY_KID”;
4.5. var endpoint = “https:// sandbox . api .service.nhs.uk/hello-world/hello/application” (without the spaces); -
I ran the code and I got the following answer in AccessToken method:
5.1. StatusCode: 401;
5.2. ReasonPhrase: ‘Unauthorized’;
5.3. Version: 1.1;
5.4. Content: System.Net.Http.HttpConnectionResponseContent;
Can you help me?
Thank you.
Best regards,
Tiago Marçal