Go-github: Error when creating a repository

Created on 5 Aug 2017  路  3Comments  路  Source: google/go-github

When creating a repository using the following method
repos, _, err := client.Repositories.Create(ctx, "", repo)
It throws the following error

POST https://api.github.com/user/repos: 404 Not Found
The client was created using the following method

        ctx := context.Background()
    ts := oauth2.StaticTokenSource(
        &oauth2.Token{AccessToken: <token returned from github after oauth>},
    )
    tc := oauth2.NewClient(ctx, ts)

    client := github.NewClient(tc)


question

Most helpful comment

@shurcooL the problem was with OAuth scopes. I don't know how i missed it.Thank you so much.

All 3 comments

404 is a strange response.

https://developer.github.com/v3/repos/#create are the GutHub API docs for that endpoint.

Do you have the right OAuth scopes? Did you provide the required Repository.Name field?

This is the repository var which i user

                repo := &github.Repository{
            Name:    github.String(RepoName),
            Private: github.Bool(false),
        }

I am able to successfully list the repositories of the same user, using the same client by the following method.
repos, _, err := client.Repositories.List(ctx, "", nil)

But i'm getting the above mentioned error when trying the create a repo.

@shurcooL the problem was with OAuth scopes. I don't know how i missed it.Thank you so much.

Was this page helpful?
0 / 5 - 0 ratings