{"id":21477479,"url":"https://github.com/spectralops/github-scopes-rs","last_synced_at":"2025-07-15T10:33:23.230Z","repository":{"id":57680686,"uuid":"495004113","full_name":"SpectralOps/github-scopes-rs","owner":"SpectralOps","description":"Discover GitHub token scope permission and return you an easy interface for checking token permission before querying GitHub.","archived":false,"fork":false,"pushed_at":"2022-09-20T18:13:27.000Z","size":25,"stargazers_count":12,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-10-29T22:47:31.927Z","etag":null,"topics":["github","github-api","oauth-app","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SpectralOps.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-05-22T08:40:37.000Z","updated_at":"2024-07-19T13:54:37.000Z","dependencies_parsed_at":"2022-09-01T14:52:08.567Z","dependency_job_id":null,"html_url":"https://github.com/SpectralOps/github-scopes-rs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpectralOps%2Fgithub-scopes-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpectralOps%2Fgithub-scopes-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpectralOps%2Fgithub-scopes-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpectralOps%2Fgithub-scopes-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SpectralOps","download_url":"https://codeload.github.com/SpectralOps/github-scopes-rs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226033248,"owners_count":17563126,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["github","github-api","oauth-app","rust"],"created_at":"2024-11-23T11:13:48.693Z","updated_at":"2024-11-23T11:13:49.345Z","avatar_url":"https://github.com/SpectralOps.png","language":"Rust","readme":"# github-scopes-rs\n\n[![Tests](https://github.com/SpectralOps/github-scopes-rs/actions/workflows/ci.yml/badge.svg)](https://github.com/SpectralOps/github-scopes-rs/actions/workflows/ci.yml)\n\nDiscover GitHub token scope permission and return you an easy interface for checking token permission before querying GitHub.\nIn many cases, you try to do actions to GitHub, but you get unclear permissions errors. This project allows you to get which permission your token has before, called GitHub, and if you don’t have the right permissions, you can tell the user the exact permission the user needs.\n\n## How it works\nWe called Github api with the given token and get which permissions scope the token has in order the access to the API. Then, the permissions are being converted to a simple object that you can work with.\nclick [here](https://docs.github.com/en/developers/apps/building-oauth-apps/scopes-for-oauth-apps) read GitHub documentation.\n\n\n## Usage\nAdd this to Cargo.toml:\n```toml\n[dependencies]\ngithub-scopes-rs = { version = \"1.0.0\" }\n```\n\nHere's a simple example\n```rs\nfn main() -\u003e AnyResult\u003c()\u003e {\n    let permissions = match OAuthContext::new(\"token\") {\n        Ok(s) =\u003e s.get_scope_permissions(),\n        Err(e) =\u003e return Err(e),\n    };\n\n    if !permissions.repo.all {\n        return Err(anyhow!(\"`repo` permission is mandatory\"));\n    }\n    Ok(())\n}\n```\n\nYou can run it by cloning this repo, and then:\n```sh\nGITHUB_TOKEN=\u003cTOKEN\u003e cargo run --example base\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspectralops%2Fgithub-scopes-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspectralops%2Fgithub-scopes-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspectralops%2Fgithub-scopes-rs/lists"}