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

Bearer Authentication #1051

Open
Bill-Niz opened this issue Aug 23, 2023 · 4 comments
Open

Bearer Authentication #1051

Bill-Niz opened this issue Aug 23, 2023 · 4 comments

Comments

@Bill-Niz
Copy link

Hello,
I'm trying to implement Bearer Authentication.
But i can't override Authentication factory.
What's the preferred way to implement Bearer Authentication?
Thanks.

@fpaaske
Copy link

fpaaske commented Nov 6, 2023

You can provide the header with the token in the different SIP message classes' extraHeaders.
For example here in the Registerer: https://github.com/onsip/SIP.js/blob/main/docs/api/sip.js.registereroptions.md

new Registerer(this.userAgent, {
  extraHeaders: ['Authorization: Bearer <token>']
});

@jagrodal
Copy link

When the token expires we want to send a new one (refreshed token) in the next REGISTER. Is this possible somehow? How can we manipulate headers in the next REGISTER message?

@Bill-Niz
Copy link
Author

@jagrodal You can re-register again using the new bearer
registerer.register({ requestOptions: { extraHeaders: "Authorization: Bearer ey......", }, })

@jagrodal
Copy link

@jagrodal You can re-register again using the new bearer registerer.register({ requestOptions: { extraHeaders: "Authorization: Bearer ey......", }, })

Will probably work, but I prefer using the built-in re-register mechanism. I ended up extending the Transport implementation and overriding the send() method (inserting the auth header here). Seems to be working. Thanks anyway!

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

3 participants