all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: zimoun <zimon.toutoune@gmail.com>
To: Guix Devel <guix-devel@gnu.org>
Subject: Re: issue with SWH ratelimit (authorization via HTTP header)
Date: Thu, 14 Oct 2021 21:01:15 +0200	[thread overview]
Message-ID: <86o87rph1g.fsf@gmail.com> (raw)
In-Reply-To: <86tuhjpif8.fsf@gmail.com>

Hi,

Thanks to Ricardo on #guix-hpc, the issue is:

    `((authorization . (Bearer ,token))))

and not ’bearer’.  Maybe the process can help.

It is misleading because the documentation [1] says to use:

--8<---------------cut here---------------start------------->8---
Enter `,help' for help.
scheme@(guix-user)> ,use(web http)
scheme@(guix-user)> (parse-header 'authorization "Bearer eyJh…")
$1 = (bearer eyJh…)
--8<---------------cut here---------------end--------------->8---

But it is not what

    (http-request URL #:method 'POST #:headers `((authorization . (bearer ,token))))

returns.

Let open a terminal and run ’emacs-simple-httpd’ as server.  The buffer
*httpd* lists what is happening.  In another terminal, let run the
request above.  Tadam!

--8<---------------cut here---------------start------------->8---
(request
 (date "Thu, 14 Oct 2021 18:41:51 GMT")
 (address "127.0.0.1")
 (get "/")
 (headers
  ("POST" "/" "HTTP/1.1")
  ("Host" "localhost:8080")
  ("Connection" "close")
  ("Authorization" "Bearer eyJh…$
  ("Content" ""))
--8<---------------cut here---------------end--------------->8---

Now, with the correct header, it works:

--8<---------------cut here---------------start------------->8---
scheme@(guix-user)> ,use(web client)
scheme@(guix-user)> (http-request "https://archive.softwareheritage.org/api/1/stat/counters/" #:method 'POST #:headers `((authorization . (Bearer ,token))))
$2 = #<<response> version: (1 . 1) code: 405 reason-phrase: "Method Not Allowed" headers: ((date . #<date nanosecond: 0 second: 2 minute: 59 hour: 18 day: 14 month: 10 year: 2021 zone-offset: 0>) (server . "gunicorn/19.9.0") (content-type application/json) (vary accept cookie) (allow GET OPTIONS HEAD OPTIONS) (x-ratelimit-limit . "1200") (x-ratelimit-remaining . "137") (x-ratelimit-reset . "1634237954") (x-frame-options . "SAMEORIGIN") (content-length . 72) (via "1.1 archive.softwareheritage.org") (x-varnish . "35772607") (age . 0) (via "1.1 varnish (Varnish/6.1)") (strict-transport-security . "max-age=15768000;") (connection close)) port: #<closed: file 7f624e3f51c0>>
$4 = #vu8(123 34 101 120 99 101 112 116 105 111 110 34 58 34 77 101 116 104 111 100 78 111 116 65 108 108 111 119 101 100 34 44 34 114 101 97 115 111 110 34 58 34 77 101 116 104 111 100 32 92 34 80 79 83 84 92 34 32 110 111 116 32 97 108 108 111 119 101 100 46 34 125)
--8<---------------cut here---------------end--------------->8---


Cheers,
simon

1: <https://www.gnu.org/software/guile/manual/html_node/HTTP-Headers.html>


  reply	other threads:[~2021-10-14 19:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-14 18:31 issue with SWH ratelimit (authorization via HTTP header) zimoun
2021-10-14 19:01 ` zimoun [this message]
2021-10-15 16:29   ` Maxim Cournoyer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86o87rph1g.fsf@gmail.com \
    --to=zimon.toutoune@gmail.com \
    --cc=guix-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.