TS: apikey/accessToken not included in requests
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 161
- Forks
- 1.9k
- PR merge metrics
- No merged PRs in 30d
Description
Preflight checklist
- I could not find a solution in the existing issues, docs, nor discussions.
- I agree to follow this project's Code of Conduct.
- I have read and am following this repository's Contribution Guidelines.
- This issue affects my Ory Network project.
- I have joined the Ory Community Slack.
- I am signed up to the Ory Security Patch Newsletter.
Describe the bug
apiKey/accessToken does not get added to the request when using the typescript SDK, resulting in admin calls rejecting as unauthorised.
You can work around it if you set the baseOptions to specify the header yourself.
Reproducing the bug
const hydra = new OAuth2Api(new Configuration({
basePath: 'https://slug.projects.oryapis.com/',
apiKey: 'ory_pat_xyz',
}))
hydra.listOAuth2Clients().then(console.log).catch(console.error)
Relevant log output
{
"error": {
"code": 401,
"status": "Unauthorized",
"request": "e5490b83-f7d5-9399-8136-283766c823b4",
"message": "Access credentials are invalid"
}
}
Relevant configuration
No response
Version
"@ory/hydra-client": "^2.0.2"
On which operating system are you observing this issue?
Ory Network
In which environment are you deploying?
Ory Network
Additional Context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the TypeScript SDK's Configuration and OAuth2Api usage shown in the reproduction, then inspect how baseOptions are applied when listOAuth2Clients() creates a request. Verify that apiKey or accessToken is included without manually setting the header, and reproduce the example against Ory Network to confirm authenticated admin calls succeed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100