Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save darahayes/89db4fd5877409e79511fde0280c78ed to your computer and use it in GitHub Desktop.
Save darahayes/89db4fd5877409e79511fde0280c78ed to your computer and use it in GitHub Desktop.
From my post on Keycloak auth in GraphQL
import Keycloak from 'keycloak-js'
import { WebSocketLink } from 'apollo-link-ws'
var keycloak = Keycloak({
url: 'http://keycloak-server/auth',
realm: 'myrealm',
clientId: 'myapp'
})
const wsLink = new WebSocketLink({
uri: 'ws://localhost:5000/',
options: {
reconnect: true,
connectionParams: {
Authorization: `Bearer ${keycloak.token}`
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment