I’m trying to get, add and delete environment variables with the Circleci API with curl.
I’ve created a personal API token and made sure that I’ve the correct role in Github (owner).
The response for curl -u <token> https://circleci.com/api/v1.1/me
is working fine.
The following is also working fine curl -u <token> https://circleci.com/api/v1.1/project/github/username/projectname
I have no trouble to list all projects.
But when I try to do anything (get, add, delete) with environment variables I get the response ‘Permission denied’.
For example when calling curl -u <token> https://circleci.com/api/v1.1/project/github/username/projectname/envvar
or curl -u <token> https://circleci.com/api/v1.1/project/github/username/projectname/envvar/nameofvar
etc…
I’m having a hard time figuring out what I’m doing wrong. I can edit the env vars in the CircleCI ui so it’s weird I can’t do it here.
Hi @yannCI!
I’ve made sure (and tested again now) that I’m either using a personal token or using a project token with scope ‘Admin’ under the correct project.
Both returns permission denied when calling /envar, but fine for /me or /username/projectname etc.
I’ve also made sure that I have admin rights in github.
I also reproduced the behaviour by using a personal API token from a user who hasn’t access to the GitHub repository.
As you confirmed the token you use was generated for a user who has sufficient access in GitHub, I suspect permissions in CircleCI and GitHub are out of sync.
I’ve tried both to refresh permission and performed a full re-authentication but no success.
Can still get all user and project details but no access to /envvar.
Could it have something to do with that my user is listed as an organization in the “ORGANIZATIONS” tab in the left header?
I see following in that tab:
Organizations
GH
GH