Unable to make the API work


#1

Hello,

First, thanks a lot for bringing Shinyproxy to the community. It’s a great tool !
I’m excited by the new API features but can’t make it work, or at least partly.
The setup :
I have the minimal dockerized shinyproxy with docker engine running, built directly from the latest github repo.

So while in my browser, in can execute all the GET endpoints.
From curl, and python requests.GET(), I can access the api/proxyspec endpoint, and I get a fine json that I can parse. However the /api/proxy endpoint is not working. I receive a 200 status code and an empty array, with the following headers (even though the 01_hello container is launched):
{
‘Expires’:‘0’,
‘Cache-Control’:‘no-cache, no-store, max-age=0, must-revalidate’,
‘X-XSS-Protection’:‘1; mode=block’,
‘Pragma’:‘no-cache’,
‘Date’:‘Sun, 03 Feb 2019 10:20:55 GMT’,
‘Connection’:‘keep-alive’,
‘X-Content-Type-Options’:‘nosniff’,
‘Transfer-Encoding’:‘chunked’,
‘Content-Type’:‘application/json;charset=UTF-8’
}

This endpoint works finely directly from the browser, where I get the expected json.

When I try to launch the 01_hello container via curl -X POST http://localhost:8080/api/proxy/01_hello i get a 400 bad request, with the 400 error html page.

I set up a flask webserver running on a docker container on localhost:80, serving the minimal ajax API control page from the github repo
It’s not working and I get a CORS header problem, according to firefox.

So, I’m puzzled, and can’t figure out why it’s not working. Could someone give me a hint ?

Cheers,
Matthieu


#2

Hi @Matthieu_Mulot,

I think there are 2 issues in play here:

  1. The endpoint POST /api/proxy/{proxySpecId} requires a JSON body, even though it’s not used for any purpose. That’s a bug, we will fix this in an upcoming release. As a workaround, you can add a body using a curl like this:

    curl --data “[]” -H “Content-Type: application/json” -X POST http://localhost:8080/api/proxy/01_hello

  2. Getting an empty array from GET /api/proxy may be an authentication issue, where the browser session and curl session cannot see each other’s proxies. What type of authentication are you using?


#3

Thank you for your answer.

Using an empty json did actually work, thanks for the tip !
However I still get an empty array with the GET method to api/proxy, with identification disabled (set to none).

But the good thing is that I can now launch containers from my website. thanks !


#4

Hi @Matthieu_Mulot,

The fix has been released as part of ShinyProxy 2.2.0 (see https://www.shinyproxy.io/downloads/). Note that it is now also possible to secure the ShinyProxy API using OAuth 2.0.

Best,
Tobias