Closed r78v10a07 closed 2 months ago
Have you tried setting a "global" token as described here? https://igv.org/doc/igvjs/#OAuth/#setting-the-token-globally
Actually I'm not sure that will work as you have no access to "igv" if using igv-webapp. There might not be a solution at the moment.
I actually don't understand your previous solution, its not obvious how that works with the webapp.
The "global" token worked fine. Thanks!
@r78v10a07 How did you access "igv" to make the function call? I don't see that its exposed from igv-webapp.
@r78v10a07 This is an important question as it looks like I need to add a method to access the "igv" API, but you somehow managed to to it. I assume you are using igv-webapp as that is where this issue is posted, and not igv.js directly. Could you elaborate?
You're correct. I was trying to access the igv API as there are a lot of methods already implemented like json load that could be used while adding custom code to igv-webapp. In this specific case the global token worked well but I agree that you should expose the IGV methods so they can be used in igv-webapp.
But you were able to access it ("igv"), how?
I was using igv-webapp version 1.3.0 and this variable was available igv.xhr
That variable allow me to use methods like this
let json = await igv.xhr.loadJson(path);
@r78v10a07 That is not part of the API and will not be in the future, you are simply using a global in the earlier version. There are no globals, or should not be, in recent versions. If you want to load json there are plenty of javascript ways to do it outside of IGV. I would recommend using "fetch". But this is not really an IGV question.
My immediate concern is how you were able to set the global access token since "igv" is not exposed. Could you show me the code you used to do that?
Sorry to pile on questions, but I have a more fundamental one. As opposed to igv.js, igv-webapp is a complete self-contained application. I don't even understand from where you would call an API. You must be modifying the html (index.html) in some custom way. That is not something the webapp supports, so its difficult to give straightforward answers to your questions.
This is the code in the igv-webapp app.js
file
import igv from '../node_modules/igv/dist/igv.esm.min.js'
...
async function main(container, config) {
AlertSingleton.init(container)
const host_url = new URL(host)
igv.setOauthToken(token, "*" + host_url.host + "*");
console.log("setOauthToken for host", "*" + host_url.host + "*");
...
}
Ok that will work, but where is that code? Are you modifying index.html?
If you are modifying index.html you do not need an api to get to "igv", you are doing it directly. In that case the complete igv.js. API is already available to you. Again it is documented here: https://igv.org/doc/igvjs/#
Or you are modifying app.js?
I'm modifying the igv-webapp app.js file
Got it, messages crossed. Exposing "igv" would not do any good unless you are using custom html. What is needed for this particular case is simply a means to set the oauth token in the igvwebConfig.js file, which is designed to be customizable. Modifying app.js is of course not a recommended long term solution.
Ok. Thanks.
Lets leave this open until a configuration parameter is available.
Actually I can't think of a secure way to set the oAuth token in the configuration file. So your solution is as good as any.
Hi, Our server uses
oauthToken
for serving the URL and indexes. We need to insert the current token into the session file before loading the data.This is the session file we save but when trying to load it, I don't know how to put the
oauthToken
before loading the data.My current code to load the session file is:
I need to load the json and insert the active token before loading the data.
We just to do that with the old version using
igv.xhr.loadJson(path)
but this is not available in the latest version. So the question is how can I use the internalloadJson
method in theigv-webapp
code