Skip to content

Are fine-grained personal access tokens supported? #742

Open
@jschwe

Description

@jschwe

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions