Hello Guix!

Just used `guix refresh enchive` and received this email from github:

> On February 12th, 2020 at 09:19 (UTC) your personal access token (guix 
> refresh) using GNU Guile was used as part of a query parameter to access an 
> endpoint through the GitHub API:

> https://api.github.com/repositories/83831780/releases

> Please use the Authorization HTTP header instead, as using the `access_token` 
> query parameter is deprecated and will be removed July 1st, 2020.

> Depending on your API usage, we'll be sending you this email reminder once 
> every 3 days for each token and User-Agent used in API calls made on your 
> behalf.
> Just one URL that was accessed with a token and User-Agent combination will 
> be listed in the email reminder, not all.

> Visit 
> https://developer.github.com/changes/2019-11-05-deprecated-passwords-and-authorizations-api/#authenticating-using-query-parameters
>  for more information.

> Thanks,
> The GitHub Team

I think the code responsible is import/github.scm:159

A tentative fix is attached, but I'm not sure how to test it


Thanks, Nicolò

>From f5f3b4c88dbc18702581e897354ac14a2763c8aa Mon Sep 17 00:00:00 2001
From: nixo <nic...@nixo.xyz>
Date: Wed, 12 Feb 2020 10:34:11 +0100
Subject: [PATCH] try fix github

---
 guix/import/github.scm | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/guix/import/github.scm b/guix/import/github.scm
index df5f6ff32f..54054cb343 100644
--- a/guix/import/github.scm
+++ b/guix/import/github.scm
@@ -150,22 +150,19 @@ empty list."
                    (github-user-slash-repository url)
                    "/tags"))
 
-  (define headers
+  (define (headers)
     ;; Ask for version 3 of the API as suggested at
     ;; <https://developer.github.com/v3/>.
     `((Accept . "application/vnd.github.v3+json")
-      (user-agent . "GNU Guile")))
+      (user-agent . "GNU Guile")
+      ,(when (%github-token)
+         `(Authorization . ,(string-append "token " (%github-token))))))
 
-  (define (decorate url)
-    (if (%github-token)
-        (string-append url "?access_token=" (%github-token))
-        url))
-
-  (match (json-fetch (decorate release-url) #:headers headers)
+  (match (json-fetch release-url #:headers (headers))
     (#()
      ;; We got the empty list, presumably because the user didn't use GitHub's
      ;; "release" mechanism, but hopefully they did use Git tags.
-     (json-fetch (decorate tag-url) #:headers headers))
+     (json-fetch tag-url #:headers (headers)))
     (x x)))
 
 (define (latest-released-version url package-name)
-- 
2.25.0

Reply via email to