5 Jun 2017 |
@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 |
@gitter_keflavich:matrix.org | In [319]: result1b = S.post('http://archive.noao.edu/search/send_simple_query', data=dd) | 15:43:44 |
@gitter_keflavich:matrix.org | Redacted or Malformed Event | 15:43:44 |
@gitter_keflavich:matrix.org | In [320]: assert result1b.text == 'OK' | 15:43:45 |
@gitter_keflavich:matrix.org | Redacted or Malformed Event | 15:43:46 |
@gitter_keflavich:matrix.org | In [321]: result2b = S.post('http://archive.noao.edu/search/list_resources') | 15:43:47 |
@gitter_keflavich:matrix.org | Redacted or Malformed Event | 15:43:48 |