{"id":23382242,"url":"https://github.com/sidoshi/gh-valid","last_synced_at":"2025-10-04T16:40:14.760Z","repository":{"id":66110905,"uuid":"132945356","full_name":"sidoshi/gh-valid","owner":"sidoshi","description":"Check if a GitHub token is valid and has the right scopes","archived":false,"fork":false,"pushed_at":"2018-05-10T19:29:00.000Z","size":61,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-01T14:21:13.893Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sidoshi.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-05-10T19:28:01.000Z","updated_at":"2023-03-10T09:31:10.000Z","dependencies_parsed_at":null,"dependency_job_id":"5d809475-95db-4f10-a3ec-5dcd40a44f56","html_url":"https://github.com/sidoshi/gh-valid","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/sidoshi%2Fgh-valid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sidoshi%2Fgh-valid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sidoshi%2Fgh-valid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sidoshi%2Fgh-valid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sidoshi","download_url":"https://codeload.github.com/sidoshi/gh-valid/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247808225,"owners_count":20999679,"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":[],"created_at":"2024-12-21T21:19:04.752Z","updated_at":"2025-10-04T16:40:09.664Z","avatar_url":"https://github.com/sidoshi.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gh-valid\n\n[![Build Status](https://travis-ci.org/sidoshi/gh-valid.svg?branch=master)](https://travis-ci.org/sidoshi/gh-valid) [![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/sidoshi/gh-valid/issues) [![HitCount](http://hits.dwyl.io/sidoshi/gh-valid.svg)](http://hits.dwyl.io/sidoshi/gh-valid) [![npm](https://img.shields.io/npm/v/gh-valid.svg)](https://www.npmjs.com/package/gh-valid) [![npm](https://img.shields.io/npm/l/gh-valid.svg)](https://www.npmjs.com/package/gh-valid)\n\n\u003e Check if a GitHub token is valid and has the right scopes\n\n## Install\n\n```bash\nnpm install --save gh-valid\n```\n\n## Usage\n\n```js\nimport ghValid from 'gh-valid'\n\n// A github token with notification and repo scope\nconst token = process.env.GITHUB_TOKEN\n\n// Check if the token is valid\nghValid(token).then(({ tokenValid, scopesValid, scopes }) =\u003e {\n  console.log(tokenValid) // true\n  console.log(scopesValid) // true\n  console.log(scopes) // ['notifications', 'repo']\n})\n\n// Check if a token is valid and has required scopes\nghValid(token, ['notification', 'gists']).then(\n  ({ tokenValid, scopesValid, scopes }) =\u003e {\n    console.log(tokenValid) // true\n    console.log(scopesValid) // false, Since gists scope is not available\n    console.log(scopes) // ['notifications', 'repo']\n  }\n)\n\n// When token is invalid\nghValid('invalid_token').then(({ tokenValid, scopesValid, scopes }) =\u003e {\n  console.log(tokenValid) // false\n  console.log(scopesValid) // false\n  console.log(scopes) // []\n})\n```\n\n## License\n\nMIT © [Siddharth Doshi](https://sid.sh)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsidoshi%2Fgh-valid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsidoshi%2Fgh-valid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsidoshi%2Fgh-valid/lists"}