Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Are fine-grained personal access tokens supported? #742

Open
jschwe opened this issue Dec 17, 2024 · 0 comments
Open

Are fine-grained personal access tokens supported? #742

jschwe opened this issue Dec 17, 2024 · 0 comments

Comments

@jschwe
Copy link

jschwe commented Dec 17, 2024

I've been trying to use octocrab to replace a bash script which uses gh api, however I can't get the authentication to work.

For the folllowing code

    /// this token has the required permissons per the github documentation and works fine when using `gh api`
    let auth_token = std::env::var("GITHUB_TOKEN")
    .context("GITHUB_TOKEN is required to authenticate with the Github API")?;
    let crab = octocrab::OctocrabBuilder::new()
        .personal_token(auth_token)
        .build()
        .context("Failed to construct Octocrab configuration")?;

    let jit_config = crab
        .actions()
        .create_repo_jit_runner_config(
            config.owner,
            config.repo,
            config.name,
            config.runner_group_id.into(),
            config.labels,
        )
        .send()
        .await?;

Octocrab gives this error:

...
[2024-12-17T07:15:51Z DEBUG octocrab] HTTP; http.status_code=403
[2024-12-17T07:15:51Z DEBUG octocrab] HTTP; otel.status_code="ERROR"
Error: Failed to spawn runner

Caused by:
    0: GitHub
    1: Forbidden
       Documentation URL: https://docs.github.com/rest/actions/self-hosted-runners#create-configuration-for-a-just-in-time-runner-for-a-repository

Can octocrab only be used for making github apps or am I doing something wrong here? As mentioned above the same token works perfectly when using gh api.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant