When I try to create an issue with go-github
API using a personal access token it responds with a 401 bad credentials
error:
POST https://api.github.com/repos/mh-cbon/demotest/issues: 401 Bad credentials []
I am using the following code:
input := &github.IssueRequest{
Title: &g.IssueTitle,
Body: &body,
}
ts := oauth2.StaticTokenSource(
&oauth2.Token{AccessToken: g.Token},
)
tc := oauth2.NewClient(oauth2.NoContext, ts)
client := github.NewClient(tc)
_, _, err = client.Issues.Create(g.Owner, g.Repo, input)
The g.Token
is the value of the token I created with the following permissions:
repo
repo:status
repo:repo_deployment
repo:public_repo
user
user:email
user:follow