Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TS: apikey/accessToken not included in requests #1932

Open
6 tasks done
joshbalfour opened this issue Mar 17, 2023 · 5 comments
Open
6 tasks done

TS: apikey/accessToken not included in requests #1932

joshbalfour opened this issue Mar 17, 2023 · 5 comments
Labels
bug Something is not working.

Comments

@joshbalfour
Copy link
Contributor

Preflight checklist

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

@joshbalfour joshbalfour added the bug Something is not working. label Mar 17, 2023
@joshbalfour
Copy link
Contributor Author

Weirdly i found this did work when using ProjectAPI from "@ory/client": "^1.1.21"

@jonas-jonas
Copy link
Member

Hi, thanks for the report. When working with the Ory Network, we recommend using the @ory/client package. @ory/hydra-client is meant to be used with standalone Hydra instances.

Though, I also only got that working when using the accessToken parameter, not apiKey.

Also, just noticed that this report is a month old, sorry for the delay.

@glawler
Copy link

glawler commented May 18, 2023

I see this in @ory/kratos-client as well. We self-host so do not use @ory/client. Periodically the token does not get added to requests. I've not been able to track down what specifically causes this though.

@GauthierPLM
Copy link

I encountered the same issue while switching from @ory/kratos-client to @ory/client: the apiKey parameter is ignored and we have to use the accessToken with a project API key instead.

Why is there two parameters, and why apiKey does not accept the actual API given by Ory?

There are no example in your documentation showing how to use the SDKs, so it's virtually impossible to know without searching in this repo' issues...

@aeneasr
Copy link
Member

aeneasr commented Oct 27, 2024

You need to use the accessTokenKey :)

@aeneasr aeneasr transferred this issue from ory/sdk Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is not working.
Projects
None yet
Development

No branches or pull requests

5 participants