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

Not able to pass custom header in sockjsClient #162

Open
jitugeo opened this issue Jun 9, 2020 · 4 comments
Open

Not able to pass custom header in sockjsClient #162

jitugeo opened this issue Jun 9, 2020 · 4 comments

Comments

@jitugeo
Copy link

jitugeo commented Jun 9, 2020

I,m not able to pass the token in the header using SockjsClient. Here is my code

const customHeader = { Authorization: 'Basic token' };
this.stompClient.connect(customHeader, (res) => {
}, (error) => {
})
@lahsivjar
can you help me what I'm missing here ?
Thanks

@aminmc
Copy link

aminmc commented Jun 24, 2020

I do this and it works:

<SockJsClient
      url={`http://localhost:8080/ws`}
      topics={topics}
      headers={
          {
            Authorization: `Bearer token`,
          }
      }
      debug
      onMessage={(msg) => {
        ...do something
      }}
    />

@ur-gh
Copy link

ur-gh commented Jan 20, 2023

@aminmc   It did not work for me.. can you see what is different here when you have a moment

<SockJsClient
url={SOCKET_URL}
topics={topics}
headers={
{
Authorization: Bearer ${accessToken},
}
}
subscribeHeaders={
{
Authorization: Bearer ${accessToken},
}
}
onConnect={onConnected}
onDisconnect={console.log("Disconnected!")}
onMessage={msg => onMessageReceived(msg)}
debug={false}
/>

@ur-gh
Copy link

ur-gh commented Jan 20, 2023

@jitugeo Just wondering if you were able to find a solution to pass header? I am tryign to padd Authorization header with oauth token. Thanks!

@RapidFire05
Copy link

i also cannot get headers to stick. the back end keeps thinking the Authorization header is null even though it can correctly handle other secured endpoints. I feel like its just a formatting issue on the prop but cant seem to get it to work.

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

4 participants