We have a Tyk REST API using OIC as it’s authorization method.
And I have a graphql API.
When using the playground I put in the authorization header, but the debug log shows “Key not authorized”. As best as I can tell Tyk’s GraphQL implementation isn’t passing the header to the API.
Has anyone been successful on using GraphQL and an auth header?
Adding some more details… We set up the GraphQL API with the same OIDC auth configuration.
Then on the data source I set header: Authorization: {{ .request.headers.Authorization }}
per the documentation. I’m getting a different error now:
time="Jul 02 17:26:41" level=warning msg="JWT Invalid" api_id=24067ab67171442c5369d02cbd8bbb53 api_name="Communities Dev" error="Validation error. The 'Authorization' header did not have the correct format." mw=OpenIDMW org_id=5d5edc54fc99b200014228c1 origin= path="/v1/communities/"
time="Jul 02 17:26:41" level=warning msg="Attempted access with invalid key." api_id=24067ab67171442c5369d02cbd8bbb53 api_name="Communities Dev" key="****JWT]" mw=OpenIDMW org_id=5d5edc54fc99b200014228c1 origin= path="/v1/communities/"
After trying a couple of tests with scenario in mind, I do not think it’s possible at this time. The UDG documentation deals with the query and response data
We will be glad if you can point us to anywhere in the docs that mentions request or headers in the data source for review
But as you suggested, Graph QL does not pass the auth header across to REST. I am talking to folks internally to know if there is way to do that
In the meantime, could you explain further on what you are trying to achieve?
Just got back from the internal team. It appears the feature of injecting or parsing headers is only available from version 3.2.1 and above. Please follow our migration guide to 3.2 as there are some breaking changes
I tested it on the gateway 3.2.1 version and it works quite well. If you are migrating then please take note of the breaking changes as it could cause unforeseen issues.
is there anything in the logs? What’s the error message you’re getting?
In the meantime I’ll try to replicate this on my side in 4.0.1. There was a slight problem with Universal Data Graph in 4.0.1, it was about passing query parameters to REST upstreams, but maybe it’s also affecting headers.