Skip to content

Commit

Permalink
Strip whitespace from authentication token.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
zevv authored and dom96 committed Feb 4, 2019
1 parent 61e6afe commit 3d6dc90
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/nimblepkg/publish.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 3d6dc90

Please sign in to comment.