5 Jun 2017 |
@gitter_keflavich:matrix.org | not the cleverest backend I've worked with... | 23:10:02 |
@gitter_ayushyadav:matrix.org | haha. | 23:10:38 |
@gitter_keflavich:matrix.org | This is being returned in headers when we are passing a cookie: 'Set-Cookie': '_session_id=ec82c0f2d53ee918da6584107988c96c; domain=archive.noao.edu; path=/; HttpOnly', | 23:14:15 |
@gitter_keflavich:matrix.org | so it is ignoring the cookie we give it | 23:14:19 |
@gitter_keflavich:matrix.org | I don't know why. | 23:14:24 |
@gitter_ayushyadav:matrix.org | I'll put in a email to the datalab team about this to see if they know a workaround or some other way around this. They said they will get back to my mail later this week so hoping they can shed some light on this as well. I have also posted on their datalab forum regarding some more details of their API so that even that can be used. Currently they have a test page working which return nothing (not nothing but a test message to any query we make). The actual base-url for the API is also buried deep in their code on the gitlab repo's notebook. | 23:18:22 |
@gitter_keflavich:matrix.org | ok, it looks like we should try to approach this from the API side | 23:20:48 |
@gitter_keflavich:matrix.org | but it must be possible to reproduce web queries too | 23:21:02 |
@gitter_ayushyadav:matrix.org | Yup. some way. I'll keep digging to see if there is something we may have missed or someother way to manage this. Meanwhile if you know anyone who worked on this project in NOAO then they might be of some help directly or by connecting us to the right person. | 23:23:35 |
@gitter_keflavich:matrix.org | there might be a way… I think the token has to match the cookie... | 23:26:00 |
@gitter_keflavich:matrix.org | bingo! that's it | 23:29:00 |
@gitter_keflavich:matrix.org | ``` | 23:29:55 |
@gitter_keflavich:matrix.org | r = requests.get('http://archive.noao.edu/search/query') | 23:29:56 |
@gitter_keflavich:matrix.org | result1b = requests.post('http://archive.noao.edu/search/send_simple_query', data=dd, cookies=r.cookies, allow_redirects=False, headers={'X-CSRF-Token':BeautifulSoup(r.text, 'html5lib').find('meta',{'name':'csrf-token'}).attrs['content']}) | 23:29:56 |
@gitter_keflavich:matrix.org | ``` | 23:29:57 |
@gitter_keflavich:matrix.org | the token & cookies should be dumped into the Session headers... | 23:30:25 |
@gitter_keflavich:matrix.org | ``` | 23:33:36 |
@gitter_keflavich:matrix.org | r = S.get('http://archive.noao.edu/search/query') | 23:33:36 |
@gitter_keflavich:matrix.org | S.headers['X-CSRF-Token'] = BeautifulSoup(r.text, 'html5lib').find('meta',{'name':'csrf-token'}).attrs['content'] | 23:33:36 |
@gitter_keflavich:matrix.org | result1b = S.post('http://archive.noao.edu/search/send_simple_query', data=dd) | 23:33:36 |
@gitter_keflavich:matrix.org | assert result1b.text == 'OK' | 23:33:36 |
@gitter_keflavich:matrix.org | result2b = S.post('http://archive.noao.edu/search/list_resources') | 23:33:37 |
@gitter_keflavich:matrix.org | ``` | 23:33:37 |
@gitter_keflavich:matrix.org | The first post is now fine, but list_resources is still problematic. | 23:33:37 |
6 Jun 2017 |
@gitter_keflavich:matrix.org | r = requests.post('http://archive.noao.edu/search/list_resources', headers={'X-CSRF-Token': '+UNUxNBVOawd9AwIk5PS8DfLp6/1yPxD3DFIhetvA9s=', 'Cookie':'_session_id=b661fbbd53378f03da53cee340fdc8b3'}) | 15:41:19 |
@gitter_keflavich:matrix.org | ``` | 15:43:42 |
@gitter_keflavich:matrix.org | In [317]: r = S.get('http://archive.noao.edu/search/query') | 15:43:43 |
@gitter_keflavich:matrix.org | Redacted or Malformed Event | 15:43:43 |
@gitter_keflavich:matrix.org | In [318]: S.headers['X-CSRF-Token'] = BeautifulSoup(r.text, 'html5lib').find('meta',{'name':'csrf-token'}).attrs['content'] | 15:43:44 |
@gitter_keflavich:matrix.org | Redacted or Malformed Event | 15:43:44 |