Personal Access token in Gist

Viewed 2727

I've created a personal access token (https://github.com/settings/tokens) giving Gist perms.

I'm trying to use it to create a gist but I'm getting

{
  "message": "Not Found",
  "documentation_url": "https://developer.github.com/v3"
}

My request is:

POST /gist HTTP/1.1
Host: api.github.com
Connection: close
X-Client-Data: CJO2yQEIorbJAQjBtskBCPqcygEIqZ3KAQjSncoBCKijygE=
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36
Accept-Language: en-US,en;q=0.8,es;q=0.6
Authorization: Basic blablablablablabla
Content-Length: 142

{
  "description": "the description for this gist",
  "files": {
    "file1.txt": {
      "content": "String file contents"
    }
  }
}

Can't personal tokens being used to post in gist?

1 Answers

The problem is that Basic authentication should not be used but a specific header to provide the token. The request should be:

POST /gist HTTP/1.1
Host: api.github.com
Connection: close
X-Client-Data: CJO2yQEIorbJAQjBtskBCPqcygEIqZ3KAQjSncoBCKijygE=
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36
Accept-Language: en-US,en;q=0.8,es;q=0.6
Authorization: token aabbaabbaabbabababababababababababababab
Content-Length: 142  

{
  "description": "the description for this gist",
  "files": {
    "file1.txt": {
      "content": "String file contents"
    }
  }
}
Related