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

Fixes missing Bearer in token auth #279

Merged
merged 3 commits into from
Jul 27, 2023

Conversation

jackcviers
Copy link
Contributor

Open ai now requires the authorization header to contain the Bearer scheme. This was resulting in errors like the below:

src-server-1 | Caused by: io.ktor.client.plugins.ClientRequestException: Client request(POST https://api.openai.com/v1/embeddings) invalid: 401 Unauthorized. Text: "{
src-server-1 | "error": {
src-server-1 | "message": "You didn't provide an API key. You need to provide your API key in an Authorization header using Bearer auth (i.e. Authorization: Bearer YOUR_KEY), or as the password field (with blank username) if you're accessing the API from your browser and are prompted for a username and password. You can obtain an API key from https://platform.openai.com/account/api-keys.",
src-server-1 | "type": "invalid_request_error",
src-server-1 | "param": null,
src-server-1 | "code": null
src-server-1 | }
src-server-1 | }
src-server-1 | "

This can be corrected by setting the headers in the openai client to mapof("Authorization" to Bearer <token>").

Open ai now requires the authorization header to contain the Bearer
scheme. This was resulting in errors like the below:

src-server-1   | Caused by: io.ktor.client.plugins.ClientRequestException: Client request(POST https://api.openai.com/v1/embeddings) invalid: 401 Unauthorized. Text: "{
src-server-1   |     "error": {
src-server-1   |         "message": "You didn't provide an API key. You need to provide your API key in an Authorization header using Bearer auth (i.e. Authorization: Bearer YOUR_KEY), or as the password field (with blank username) if you're accessing the API from your browser and are prompted for a username and password. You can obtain an API key from https://platform.openai.com/account/api-keys.",
src-server-1   |         "type": "invalid_request_error",
src-server-1   |         "param": null,
src-server-1   |         "code": null
src-server-1   |     }
src-server-1   | }
src-server-1   | "

This can be corrected by setting the headers in the openai client to
`mapof("Authorization" to Bearer <token>")`.
@anamariamv anamariamv requested review from a team, javipacheco and victorcrrd and removed request for a team July 27, 2023 16:12
@raulraja raulraja merged commit 47b3fc1 into xebia-functional:main Jul 27, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants