Konubinix' opinionated web of thoughts

Corriger Hypothesis

Fleeting

corriger hypothesis.el

En regardant comment c’est fait, ça appelle

curl -L --request GET --header 'Hypothesis-Media-Type: application/vnd.hypothesis.v1+json' --header 'Accept: application/vnd.hypothesis.v1+json' --header "Authorization: Bearer ${BEARER}" --url "http://hypothes.is/api/search?user=acct:${USERNAME}@hypothes.is"|jq -r '.total, .rows[].created'

Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0

100  2220    0  2220    0     0   2487      0 --:--:-- --:--:-- --:--:--  2487
100 30957    0 30957    0     0  34586      0 --:--:-- --:--:-- --:--:-- 13.7M
26
2022-07-12T03:34:45.333790+00:00
2022-07-11T05:57:51.777824+00:00
2022-05-05T04:54:37.158972+00:00
2022-02-26T22:01:53.047735+00:00
2022-02-14T06:32:04.531784+00:00
2022-02-14T06:50:53.961079+00:00
2022-02-14T06:43:58.170050+00:00
2022-01-31T05:37:24.083306+00:00
2021-01-19T06:05:08.580529+00:00
2021-10-15T08:46:11.722195+00:00
2021-10-14T09:32:24.924407+00:00
2021-10-14T09:12:43.823005+00:00
2021-10-14T09:16:13.397727+00:00
2021-09-18T18:40:12.167875+00:00
2021-05-07T05:35:59.432980+00:00
2021-04-19T21:16:17.332504+00:00
2021-04-08T05:39:11.770418+00:00
2021-02-07T21:53:45.184461+00:00
2021-01-13T06:32:44.362242+00:00
2021-01-13T06:26:45.691697+00:00

Que des vieux trucs, et pas beaucoup (seulement 26 résultats).

En testant avec http, j’ai les bons résultats.

http --session hypothesis -F "http://hypothes.is/api/search?user=acct:${USERNAME}@hypothes.is"  "Authorization: Bearer ${BEARER}" |jq -r '.total, .rows[].created'
4203
2022-09-06T04:45:10.234813+00:00
2022-09-06T04:44:54.506537+00:00
2022-09-06T04:44:29.900954+00:00
2022-09-06T04:44:23.066705+00:00
2022-09-06T04:44:18.329420+00:00
2022-09-06T04:44:11.509760+00:00
2022-09-05T20:52:47.766406+00:00
2022-09-05T20:52:32.904159+00:00
2022-09-05T20:52:03.614335+00:00
2022-09-05T20:51:42.252378+00:00
2022-09-04T07:40:18.035146+00:00
2022-08-25T05:46:22.033691+00:00
2022-08-25T05:45:46.496650+00:00
2022-08-25T05:45:35.249834+00:00
2022-08-25T05:45:10.005882+00:00
2022-08-25T05:44:59.945947+00:00
2022-08-25T05:44:49.906973+00:00
2022-08-25T05:44:43.436983+00:00
2022-08-25T05:44:28.585258+00:00
2022-08-18T09:43:14.200885+00:00

4184 résultats, voilà qui est déjà mieux.

C’est peut être lié à la redirection par cloudflare.

curl -i -L --request GET --header "Authorization: Bearer ${BEARER}" --url "http://hypothes.is/api/search?user=acct:${USERNAME}@hypothes.is"|sed -e 's/\x1b\[[0-9;]*m//g'

Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
HTTP/1.1 301 Moved Permanently
Date: Wed, 24 Aug 2022 13:55:27 GMT
Transfer-Encoding: chunked
Connection: keep-alive
Cache-Control: max-age=3600
Expires: Wed, 24 Aug 2022 14:55:27 GMT
Location: https://hypothes.is/api/search?user=acct:...@hypothes.is
X-Content-Type-Options: nosniff
Server: cloudflare
CF-RAY: 73fc95f13e8ed3d8-CDG
alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400

HTTP/2 200
date: Wed, 24 Aug 2022 13:55:27 GMT
content-type: application/json
content-security-policy: font-src 'self' fonts.gstatic.com cdn.hypothes.is; script-src 'self' cdn.hypothes.is www.google-analytics.com; style-src 'self' fonts.googleapis.com cdn.hypothes.is 'unsafe-inline'
hypothesis-media-type: application/vnd.hypothesis.v1+json
access-control-allow-origin: *
etag: W/"................"
referrer-policy: origin-when-cross-origin, strict-origin-when-cross-origin
x-xss-protection: 1; mode=block
cache-control: no-cache
cf-cache-status: DYNAMIC
expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
strict-transport-security: max-age=15552000; includeSubDomains; preload
x-content-type-options: nosniff
server: cloudflare
cf-ray: xxxxxxxxxxx
alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400


100 30957    0 30957    0     0  71003      0 --:--:-- --:--:-- --:--:-- 71003

Et avec http

http --headers -F "http://hypothes.is/api/search?user=acct:${USERNAME}@hypothes.is"  "Authorization: Bearer ${BEARER}"
HTTP/1.1 200 OK
CF-Cache-Status: DYNAMIC
CF-RAY: 73fc97b7bb67d33f-CDG
Cache-Control: no-cache
Connection: keep-alive
Content-Encoding: gzip
Content-Type: application/json
Date: Wed, 24 Aug 2022 13:56:40 GMT
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Server: cloudflare
Strict-Transport-Security: max-age=15552000; includeSubDomains; preload
Transfer-Encoding: chunked
X-Content-Type-Options: nosniff
access-control-allow-origin: *
alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400
content-security-policy: font-src 'self' fonts.gstatic.com cdn.hypothes.is; script-src 'self' cdn.hypothes.is www.google-analytics.com; style-src 'self' fonts.googleapis.com cdn.hypothes.is 'unsafe-inline'
etag: W/"FG+6n90+TcKNCmqNVrq/wQ"
hypothesis-media-type: application/vnd.hypothesis.v1+json
referrer-policy: origin-when-cross-origin, strict-origin-when-cross-origin
x-xss-protection: 1; mode=block
from clk.lib import check_output
BEARER = check_output(["impass_dump_clear_password.sh", "token@hypothes.is"])
USERNAME = check_output (["impass_dump_clear_password.sh", "username@hypothes.is"])
import requests

resp = requests.get(
    f"http://hypothes.is/api/search?user=acct:{USERNAME}@hypothes.is&limit=200",
    headers={
        "Authorisation":
        f"Bearer {BEARER}",
        'User-Agent': 'HTTPie/3.2.1',
        'Connection': 'keep-alive',
        'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*',
    },
)
result = resp.json()
[[result["total"]]] + [[row["created"]] for row in result["rows"]]
26
2022-07-12T03:34:45.333790+00:00
2022-07-11T05:57:51.777824+00:00
2022-05-05T04:54:37.158972+00:00
2022-02-26T22:01:53.047735+00:00
2022-02-14T06:32:04.531784+00:00
2022-02-14T06:50:53.961079+00:00
2022-02-14T06:43:58.170050+00:00
2022-01-31T05:37:24.083306+00:00
2021-01-19T06:05:08.580529+00:00
2021-10-15T08:46:11.722195+00:00
2021-10-14T09:32:24.924407+00:00
2021-10-14T09:12:43.823005+00:00
2021-10-14T09:16:13.397727+00:00
2021-09-18T18:40:12.167875+00:00
2021-05-07T05:35:59.432980+00:00
2021-04-19T21:16:17.332504+00:00
2021-04-08T05:39:11.770418+00:00
2021-02-07T21:53:45.184461+00:00
2021-01-13T06:32:44.362242+00:00
2021-01-13T06:26:45.691697+00:00
2021-01-11T06:40:18.641397+00:00
2021-01-05T21:42:51.511282+00:00
2021-01-03T19:04:25.225399+00:00
2021-01-02T20:00:31.623041+00:00
2021-01-02T20:02:18.372213+00:00
2020-12-31T22:47:46.988559+00:00

I get the same behavior than curl does.

changing the url

import requests

resp = requests.get(
    f"https://api.hypothes.is/api/search?user=acct:{USERNAME}@hypothes.is",
    headers={
        "Authorisation":
        f"Bearer {BEARER}",
    },
    allow_redirects=True,
)
result = resp.json()
[[result["total"]]] + [[row["created"]] for row in result["rows"]]
26
2022-07-12T03:34:45.333790+00:00
2022-07-11T05:57:51.777824+00:00
2022-05-05T04:54:37.158972+00:00
2022-02-26T22:01:53.047735+00:00
2022-02-14T06:32:04.531784+00:00
2022-02-14T06:50:53.961079+00:00
2022-02-14T06:43:58.170050+00:00
2022-01-31T05:37:24.083306+00:00
2021-01-19T06:05:08.580529+00:00
2021-10-15T08:46:11.722195+00:00
2021-10-14T09:32:24.924407+00:00
2021-10-14T09:12:43.823005+00:00
2021-10-14T09:16:13.397727+00:00
2021-09-18T18:40:12.167875+00:00
2021-05-07T05:35:59.432980+00:00
2021-04-19T21:16:17.332504+00:00
2021-04-08T05:39:11.770418+00:00
2021-02-07T21:53:45.184461+00:00
2021-01-13T06:32:44.362242+00:00
2021-01-13T06:26:45.691697+00:00