From 3d6dc90cd4dfc12b8ae9d1958e84610cf21b34bb Mon Sep 17 00:00:00 2001 From: Ico Doornekamp Date: Thu, 31 Jan 2019 20:45:16 +0100 Subject: [PATCH] Strip whitespace from authentication token. My token had a newline in the file, resulting in the following HTTP request being made to Github: ``` GET /user HTTP/1.1 Host: api.github.com Connection: Keep-Alive authorization: token xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx content-type: application/x-www-form-urlencoded accept: */* user-agent: Nim httpclient/0.19.9 ``` Unfortunately the friendly error message returned by the Github server is lost in translation because getContent() throws an exception, never handling the body. --- src/nimblepkg/publish.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nimblepkg/publish.nim b/src/nimblepkg/publish.nim index 0b07a07..2d73478 100644 --- a/src/nimblepkg/publish.nim +++ b/src/nimblepkg/publish.nim @@ -62,7 +62,7 @@ proc getGithubAuth(o: Options): Auth = # try to read from disk, if it cannot be found write a new one try: let apiTokenFilePath = cfg.nimbleDir / ApiKeyFile - result.token = readFile(apiTokenFilePath) + result.token = readFile(apiTokenFilePath).strip() display("Info:", "Using GitHub API Token in file: " & apiTokenFilePath, priority = HighPriority) except IOError: