How to Pass an Auth Token #1378
-
My editor is cloud-based and will run in a browser. I need to pass an auth token to my language server, which is running in a web worker, so that I can use it while making a call to an external REST API during scoping. Think of it like calling My first thought was to hand it in during dependency injection and then access it via shared services. But that seems like a possible misuse of the DI mechanism. Is there a recommended way for me to safely pass information like this to my scope provider and then update it when the token needs a refresh? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 9 replies
-
Hey @ballcoach12, good to see you back :) First off, it's probably best to pass the token during the Then during runtime, if the token changes, you can just send a notification to the language server. You can always listen to any custom notification: shared.lsp.Connection?.onNotification('newToken', token => {
...
}); |
Beta Was this translation helpful? Give feedback.
-
For anyone else who has a similar requirement, here is how I implemented this. In my case, I am using a worker to run the language server in the browser, which means that I am unable to obtain the cookie that contains the token because browser-side code cannot access a cookie. My implementation follows these steps:
|
Beta Was this translation helpful? Give feedback.
For anyone else who has a similar requirement, here is how I implemented this. In my case, I am using a worker to run the language server in the browser, which means that I am unable to obtain the cookie that contains the token because browser-side code cannot access a cookie.
My implementation follows these steps: