From 3d1e42321f091b815835e28b54b37b7e9c79b9bb Mon Sep 17 00:00:00 2001 From: Matt Wette Date: Sat, 22 Feb 2020 11:48:29 +0100 Subject: [PATCH] import: github: Use HTTP "Authorization" header for access tokens. Fixes . The "access_token" query parameter is now deprecated: https://developer.github.com/changes/2019-11-05-deprecated-passwords-and-authorizations-api/#authenticating-using-query-parameters * guix/import/github.scm (fetch-releases-or-tags)[headers]: Add "Authorization" header when (%github-token) is true. [decorate]: Remove, and remove callers. --- guix/import/github.scm | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/guix/import/github.scm b/guix/import/github.scm index df5f6ff32f..7136e7a34f 100644 --- a/guix/import/github.scm +++ b/guix/import/github.scm @@ -154,18 +154,16 @@ (define headers ;; Ask for version 3 of the API as suggested at ;; . `((Accept . "application/vnd.github.v3+json") - (user-agent . "GNU Guile"))) + (user-agent . "GNU Guile") + ,@(if (%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)