API on mindprobe.eu always returns login page
Dear JATOS Team,
I have tried to use the API for a recent study which requires frequent downloading of data and subsequent updating of study asset files. It works fine on the cortex test server.
When I tried it on mindprobe, I run into the problem that the server always returns a (the same) HTML file, regardless of which API endpoint I call. It seems to be the Login page (or redirect to one).
I found this to be a known problem with web servers, which redirect all requests to the Login page when a user is not logged in (probably checked via a cookie). Instead, calls to the API are authorized with the tokens, so there should be no redirect. Perhaps web server needs to be configured such that it does not redirect calls to URLs with "/api/" in it?
Is it me, or could it be a server issue?
Thank you for looking into it!
Christoph
Comments
Hi Christoph,
how are you doing your API calls? I just tried with curl and the simple `admin/token` endpoint and it worked:
$ curl -i -H "Authorization: Bearer jap_123abc" https://jatos.mindprobe.eu/jatos/api/v1/admin/token HTTP/2 200 server: nginx/1.18.0 (Ubuntu) ... {"apiVersion":"1.0.1","data":{"id":823,"name":"Christoph test","creationDate":1755613204000,"expires":2592000,"active":true,"isExpired":false,"isAdminToken":true,"expirationDate":1758205204000}}Best,
Kristian
Hi Kristian,
thanks for looking into this. Your example call also works for me initially. But when I try to get the results of a study, using R code that works for our own server, the call returns the "JATOS sign in" page as content.
This code works with our own server:
``` library(httr) auth_header = c( `Authorization` = "Bearer jap_abc") res <- httr::GET(url = paste0("https://jatos.methexp.uni-koeln.de/jatos/api/v1/results/data?studyId=", jatos_study_id), httr::add_headers(.headers=auth_header)) ```With this code, calling mindprobe, I get the sign-in page instead of the data zip file:
auth_header = c(`Authorization` = "Bearer jap_abc") res <- httr::GET(url = paste0("https://jatos.mindprobe.eu/jatos/api/v1/results/data?studyId=", "20795"), httr::add_headers(.headers=auth_header))I understand too little about networking to dig deeper into this at this point.
Best Christoph
Hi Christoph,
it also works for me with curl and getting result data jatos.mindprobe.eu.
I'm not sure what's going on in your R code. I'm not an R expert and from what I see it looks fine. Maybe if you could log the requests and responses headers I could see more (remember to delete the Token "jap_*").
Best,
Kristian