API v2 cannot be accessed with project specific API token

I trigger an new pipeline with v2 API as described here: https://github.com/CircleCI-Public/api-preview-docs/blob/master/docs/api-changes.md#post-projectproject_slugpipeline

Works like a charm if I use one of my Personal API token. But it does not work if I create a project specific API permission token (in project_slug), response from post: “Project not found”

2 Likes

Is there any progress on this? I have the exact same issue, which I wasted a couple of hours on trying all different possible ways to call the API until I found this thread.

@ndintenfass will this get fixed or at the very least well documented and maybe a more helpful error message emitted?

Hello @daaain, @kptdobe,

Project level tokens are only for read-only actions: https://circleci.com/docs/2.0/managing-api-tokens/

In order to trigger a new pipeline there must be an “actor” or someone who was responsible for kicking off that pipeline. Since projects tokens are specific to a project and not a user (and do not have write permissions), they can not be used for triggering pipelines.

A Personal Access Token is the correct way to go for all write actions.

If you require a more “general” token, what we recommend is creating a “machine user” on GitHub who’s token will act as the automated user token for that project.

https://circleci.com/docs/2.0/gh-bb-integration/#controlling-access-via-a-machine-user

I see, that makes sense (and thanks for your response!)

Can I please ask that the error message be improved from (I guess a generic 404) saying Project not found to even at least a 403 Unauthorised, but ideally something along the lines of Cannot do write actions with a read-only (project) token. Please use a personal or machine user token!

We have filed a bug report to be reviewed :+1:

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.