# Personal Demographics Service - FHIR API - Application-restricted API authentication failure

**URL:** <https://developer.community.nhs.uk/t/personal-demographics-service-fhir-api-application-restricted-api-authentication-failure/130>\
**Category:** Personal Demographics Service FHIR API\
**Tags:** authentication, integration, fhir, testing\
**Created:** [4 November 2022 13:56 UTC](https://developer.community.nhs.uk/t/personal-demographics-service-fhir-api-application-restricted-api-authentication-failure/130 "2022-11-04T13:56:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tugce](https://avatars.discourse-cdn.com/v4/letter/t/77aa72/32.png) [@tugce](https://developer.community.nhs.uk/u/tugce)\
**Post date:** [4 November 2022 13:56 UTC](https://developer.community.nhs.uk/t/personal-demographics-service-fhir-api-application-restricted-api-authentication-failure/130/1 "2022-11-04T13:56:53Z")

</div>

Hi,  
I could not authenticate to Personal Demographics Service - FHIR API - Application-restricted API by my API Key. Although i can authenticate to “Hello Application” with my API Key.  
I tried to add the Api Key to header and to query params both. I got the same error.  
I enabled the “Personal Demographics Service - Application-Restricted (Integration Testing)” service at my application. My application’s environment is “Integration test”  
The error is;

“resourceType”: “OperationOutcome”,  
“issue”: [  
{  
“severity”: “error”,  
“code”: “forbidden”,  
“details”: {  
“coding”: [  
{  
“system”: “[https://fhir.nhs.uk/R4/CodeSystem/Spine-ErrorOrWarningCode](https://fhir.nhs.uk/R4/CodeSystem/Spine-ErrorOrWarningCode)”,  
“version”: “1”,  
“code”: “ACCESS\_DENIED”,  
“display”: “Access Denied - Unauthorised”  
}  
]  
},  
“diagnostics”: “Invalid access token”  
}  
]  
}

This is the url that i want to connect.  
[https://int.api.service.nhs.uk/personal-demographics/FHIR/R4/Patient/9449306621](https://int.api.service.nhs.uk/personal-demographics/FHIR/R4/Patient/9449306621)

Could you please help me for authenticate to the integration testing environment.

Kind Regards,  
Tuğçe

---

<div class="post-metadata">

**Author:** ![ayo.odunsi1](https://dub1.discourse-cdn.com/nhsdigitaldeveloper/user_avatar/developer.community.nhs.uk/ayo.odunsi1/32/13_2.png) [@ayo.odunsi1](https://developer.community.nhs.uk/u/ayo.odunsi1)\
**Post date:** [7 November 2022 11:49 UTC](https://developer.community.nhs.uk/t/personal-demographics-service-fhir-api-application-restricted-api-authentication-failure/130/2 "2022-11-07T11:49:43Z")

</div>

Hi Tugce,

The PDS- FHIR API is [RESTful](https://digital.nhs.uk/developer/guides-and-documentation/our-api-technologies#basic-rest) and as such I would refer you to [PDS -FHIR Application-restricted RESTful API authentication page](https://digital.nhs.uk/developer/guides-and-documentation/security-and-authorisation/application-restricted-restful-apis-signed-jwt-authentication#step-2-generate-a-key-pair). You need to follow the steps highlights on that page

Just so you know, if you create multiple applications to test across multiple test environments, you also need a different key pair and KID for each environment.

I hope this helps
