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

How to pass different auth tokens for different specs? #467

Open
spinningarrow opened this issue Jun 24, 2022 · 0 comments
Open

How to pass different auth tokens for different specs? #467

spinningarrow opened this issue Jun 24, 2022 · 0 comments

Comments

@spinningarrow
Copy link

I'm using this library to wrap to different APIs and combine them into a unified graphql interface using express-graphql. I have two different specs, spec1.json and spec2.json and I'm able to create a schema by passing both of these to createGraphqlSchema.

The problem is with authentication. spec1 uses OAuth and following the suggestion in #116 (comment) I have a separate express middleware that fetches the token and puts it in the request object. When calling createGraphqlSchema, I pass in the path to this using the tokenJSONPath option.

On the other hand, spec2 uses a simple static API token which also goes into the Authorization header and I set this using the headers option in createGraphqlSchema - first I check if the title matches spec2.info.title and then I override this header.

However this seems not to work since the tokenJSONPath always takes priority. Is there a way to work around this and essentially provide different authentication tokens to different specs?

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

No branches or pull requests

1 participant