-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Support for authentication via OAuth / OpenID Connect #1775
Comments
you can use any authentication mechanism you want, just use the values in the fetcher to pass headers! the form of authn and authz doesn’t matter when it’s just http headers or websocket params in the end, right? as you can see, we have an issue open for the task of setting up a github oauth demo to demonstrate this. let me know if you have any issues with passing the token to GraphiQL once the user is authenticated! |
Thank you for your reply. Of course, the auth headers can be passed in manually - and that is a nice solution for many situations. The issue I face, however, is that my GraphQL server is protected with OIDC, and access tokens expire after an hour. With the current state of play, I must:
This is a problematic approach, especially when I am asking other developers who are consuming the API to use GraphiQL, who will not have the patience to carry out this manual process every time. I'd like to use GraphiQL over Insomnia as there is much less friction in asking a fellow developer to go to a URL vs installing and setting up a desktop client, but if this is not in scope for something that GraphiQL can support, then that's of course also fine - I appreciate that this is a large project with many other priorities. |
sounds like you can build a react app around GraphiQL for that like most of us! our user's needs are too customized to provide anything generic for this. we can't possibly accomodate every auth flow, and its easier to just allow any auth flow by supporting any as we do now. just make the react app handle the login, and present GraphiQL once the token is present. your wrapper app would make sure to keep freshing the access token. every time you pass the new fetcher into GraphiQL, all requests will start using the new token. |
#1771 (comment) to get you started this project is mostly used by customized frameworks, and by projects like insomnia who use our LSP libraries. I'm pretty much the only recurring contributor, so there is no time to support such a thing. I'm available for paid consulting if you need more help with it, but most frontend devs can figure this one out it seems! i've worked at a handful of companies where they implemented an auth flow with GraphiQL themselves. |
No problem, thank you for taking the time to reply and point me in the right direction. 🙂 |
This has been discussed in #59 but with less scope than outlined below.
The Insomina REST client has native support for authenticating with the GraphQL server via OAuth 2.0, and therefore also OpenID Connect. It will also (automatically) refresh an access token if it has expired.
This has a number of advantages:
Authorisation
header.Could GraphiQL support this?
I'd love to be able to use GraphiQL but the second point in particular is a dealbreaker for me. As it currently stands, access tokens on my GraphQL server expire after 60 mins, and so every hour I would need to manually acquire an access token and set it in GraphiQL to continue using it.
The text was updated successfully, but these errors were encountered: