Closed infomofo closed 4 years ago
Can you share how you initialize your OpenAPIClientAxios instance? How are you setting the header token?
I'm initializing my OpenAPIClientAxios method using the openapi-client-axios-typegen
method outlined in the README using the getClient
method:
import OpenAPIClientAxios from "openapi-client-axios";
import { Client } from "client";
const api = new OpenAPIClientAxios({ definition: "/api/openapi.json" });
api.init<Client>();
const client = await api.getClient<Client>();
I'm setting the header token as an axios default, as I use the same authorization token for all my api calls.
axios.defaults.headers.common["Authorization"] = "Bearer " + token
Hi @infomofo ! Could you please make sure you're setting the default headers on the axios client created by OpenAPIClientAxios
?
const client = await api.getClient<Client>();
client.defaults.headers["Authorization"] = "Bearer " + token;
@anttiviljami This suggested method of setting the bearer token worked with the latest version of axios, thanks!
Cheers! 🍺
I upgraded from
And after that, my openapi calls that use the
Bearer
Authorization
header token are consistently returning 403. Inspecting the network traffic it seems that after the axios upgrade, my generated axios client no longer is sending the requiredAuthorization
header at all. Is anyone else experiencing this? Is there a known workaround or is there a known regression with axios v0.20.0? Let me know if I can provide additional information to help demonstrate the issue I am encountering.