{"id":20485320,"url":"https://github.com/runnable/nock-github-oauth","last_synced_at":"2026-05-28T21:31:12.006Z","repository":{"id":28895202,"uuid":"32419930","full_name":"Runnable/nock-github-oauth","owner":"Runnable","description":"GitHub OAuth HTTP intercepts via nock.","archived":false,"fork":false,"pushed_at":"2017-06-19T09:32:46.000Z","size":568,"stargazers_count":2,"open_issues_count":2,"forks_count":2,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-03-05T16:27:06.574Z","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/Runnable.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":"2015-03-17T20:56:52.000Z","updated_at":"2015-09-14T17:35:33.000Z","dependencies_parsed_at":"2022-09-03T07:41:43.972Z","dependency_job_id":null,"html_url":"https://github.com/Runnable/nock-github-oauth","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/Runnable/nock-github-oauth","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Runnable%2Fnock-github-oauth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Runnable%2Fnock-github-oauth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Runnable%2Fnock-github-oauth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Runnable%2Fnock-github-oauth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Runnable","download_url":"https://codeload.github.com/Runnable/nock-github-oauth/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Runnable%2Fnock-github-oauth/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33627934,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-28T02:00:06.440Z","response_time":99,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-11-15T16:29:27.789Z","updated_at":"2026-05-28T21:31:11.982Z","avatar_url":"https://github.com/Runnable.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nock-github-oauth\n\n[![Build Status](https://travis-ci.org/Runnable/nock-github-oauth.svg?branch=master)](https://travis-ci.org/Runnable/nock-github-oauth) \n[![Dependency Status](https://david-dm.org/Runnable/nock-github-oauth.svg)](https://david-dm.org/Runnable/nock-github-oauth) \n[![devDependency Status](https://david-dm.org/Runnable/nock-github-oauth/dev-status.svg)](https://david-dm.org/Runnable/nock-github-oauth#info=devDependencies)\n[![Code Climate](https://codeclimate.com/github/Runnable/nock-github-oauth/badges/gpa.svg)](https://codeclimate.com/github/Runnable/nock-github-oauth)\n\n[![NPM](https://nodei.co/npm/nock-github-oauth.png?compact=true)](https://nodei.co/npm/nock-github-oauth/)\n\nGitHub OAuth HTTP intercepts via nock.\n\n## Installation\nVia npm: `npm install nock-github-oauth --save-dev`\n\n## Usage\n`nock-github-oauth` is meant to be used from a testing context. Specifically, it mocks the\nfollowing routes for `https://github.com:443`:\n\n* `GET /login`,\n* `GET /login/oauth/authorize`, and\n* `POST /login/oauth/access_token` (returns a mocked token in the body).\n\nThe package exposes a method (`exports.nock`) that establishes the intercepts for each of the\naforementioned Github OAuth routes. Here is an example of how to use it in a\n(https://github.com/hapijs/lab)[lab] test:\n\n```js\nvar Lab = require('lab');\nvar lab = exports.lab = Lab.script();\nvar nock = require('nock');\nvar github = require('nock-github-oauth');\n\nlab.experiment('module that depends on GitHub OAuth', function() {\n\tlab.before(function(done) {\n\t\t// Setup github oauth http intercepts\n\t\tgithub.nock(done);\n\t});\n\n\tlab.after(function(done) {\n\t\t// Remove all intercepts\n\t\tnock.cleanAll();\n\t});\n});\n```\n\nFinally, for convience, the package also exposes the https host for GitHub OAuth via\n`exports.host` (`https://github.com:443`). and the mocked oauth token returned by the\nintercepted `POST /login/oauth/access_token` via `exports.token`. You can access these\nlike so:\n\n```js\nvar github = require('nock-github-oauth');\nvar mockToken = github.token;\nvar githubHost = github.host;\n```\n\n## Contributing \u0026 Tests\n\nWhen adding new features, fixing bugs, etc. please make sure to include the appropriate\ntests and ensure all tests are passing before sending a pull request. We use `lab` for\nunit testing, here's how to run tests:\n\n```\nnpm run test\n```\n\nAdditionally you'll want to ensure the files lint:\n\n```\nnpm run lint\n```\n\n## License\n[MIT](https://raw.githubusercontent.com/Runnable/nock-github-oauth/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frunnable%2Fnock-github-oauth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frunnable%2Fnock-github-oauth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frunnable%2Fnock-github-oauth/lists"}