I used this documentation to secure some endpoints in my fastapi app. It seemed to be working fine, and I was also able to run some tests (using pytest):
...
client = TestClient(app=app)
response = client.post(
"/my_end_point",
json={'data':'model'},
headers={"Authorization": f"Bearer {token}"},
)
...
My problem is, I want to connect my app to a Gitlab Webhook, and when doing that, Gitlab sends this header:
{'x-gitlab-token':'some-token-that-can-be-defined-when-setting-up-the-webhook'}
That means, even if I configure a valid token in the Gitlab Webhook configuration, it is not accepted by my FastAPI app, which returns 401 Not authorized error.
I guess my question is how to instruct FastApi to take the token from 'x-gitlab-token' key and not from 'Authorization' key