Bearer Authentication
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.
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>']
});
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?
@jagrodal You can re-register again using the new bearer
registerer.register({ requestOptions: { extraHeaders: "Authorization: Bearer ey......", }, })
@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!