{"id":15669561,"url":"https://github.com/henrahmagix/github-oauth-prompt","last_synced_at":"2025-06-10T16:34:48.646Z","repository":{"id":20504583,"uuid":"23783117","full_name":"henrahmagix/github-oauth-prompt","owner":"henrahmagix","description":"Easy creation of GitHub OAuth tokens.","archived":false,"fork":false,"pushed_at":"2015-11-03T09:59:38.000Z","size":515,"stargazers_count":7,"open_issues_count":6,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-03T21:40:20.457Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/henrahmagix.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2014-09-08T07:56:49.000Z","updated_at":"2018-01-16T03:03:19.000Z","dependencies_parsed_at":"2022-08-21T18:21:07.110Z","dependency_job_id":null,"html_url":"https://github.com/henrahmagix/github-oauth-prompt","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/henrahmagix%2Fgithub-oauth-prompt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/henrahmagix%2Fgithub-oauth-prompt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/henrahmagix%2Fgithub-oauth-prompt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/henrahmagix%2Fgithub-oauth-prompt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/henrahmagix","download_url":"https://codeload.github.com/henrahmagix/github-oauth-prompt/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/henrahmagix%2Fgithub-oauth-prompt/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259111503,"owners_count":22806923,"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-10-03T14:40:20.710Z","updated_at":"2025-06-10T16:34:48.621Z","avatar_url":"https://github.com/henrahmagix.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# github-oauth-prompt [![Build Status](https://secure.travis-ci.org/henrahmagix/github-oauth-prompt.png?branch=master)](http://travis-ci.org/henrahmagix/github-oauth-prompt) [![Coverage Status](https://coveralls.io/repos/henrahmagix/github-oauth-prompt/badge.png)](https://coveralls.io/r/henrahmagix/github-oauth-prompt)\n\n[![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/henrahmagix/github-oauth-prompt?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n\nEasy creation of GitHub OAuth tokens.\n\nTwo-factor authentication is fully supported.\n\n## Getting Started\nInstall the module with: `npm install github-oauth-prompt`\n\n```javascript\nvar oauth = require('github-oauth-prompt');\noauth({name: 'my-token'}, function (err, token) {\n    // Now you have a token.\n});\n```\n\n## Documentation\n_(Coming soon)_\n\nSee \u003ca href=\"#examples\"\u003eExamples\u003c/a\u003e\n\n## Examples\nIn all examples below, `callback` is a function accepting two parameters: error and response.\n```js\nfunction callback (err, res) {\n    console.log('Token: ' + res);\n}\n```\n\n### Example 1\n\n```javascript\n// Prompt for username, password, two-factor auth code if required,\n// and return to the callback a GitHub token with basic scope.\noauth({\n    name: 'moonrise-kingdom'\n}, callback);\n```\n\n![moonrise-kingdom demo gif](http://i.imgur.com/f2VbL6m.gif)\n\n### Example 2\n\n```javascript\n// Prompt for a token for read/write access to all repositories\n// and organisations and write access to Gists.\n// More scopes: https://developer.github.com/v3/oauth/#scopes\noauth({\n    name: 'rushmore',\n    scopes: ['repo', 'gist']\n}, callback);\n```\n\n![rushmore demo gif](http://i.imgur.com/msW2ZYc.gif)\n\nSee that the token exists.\n\n![rushmore token in list](http://i.imgur.com/9Of7p3Z.png)\n\nWhen called again, the existing token is returned.\n\n![rushmore demo existing gif](http://i.imgur.com/2xDlLpi.gif)\n\n### Example 3\n\n```javascript\n// Set prompt messages.\noauth({\n    name: 'the-life-aquatic',\n    prompt: {\n        username: 'Enter username:',\n        password: 'Enter password:',\n        code: 'Enter two-factor authorisation code'\n    }\n}, callback);\n```\n\n![the-life-aquatic demo gif](http://i.imgur.com/oj3kgwP.gif)\n\n### Example 4\n\n```javascript\n// Use own prompt. Must deal with two-factor authentication.\n// Ask for username and password and store in an object. For this example, and\n// to avoid getting bogged down in callback-hell, we have them already available.\nvar auth = {\n    username: 'Margot',\n    password: 'RichieLovesMe'\n};\n// Setup a function to call oauth with a code.\nfunction getToken (code) {\n    // Get a token with a two-factor authentication code.\n    var authOptions = {\n        name: 'the-royal-tenenbaums'\n        username: auth.username,\n        password: auth.password,\n    };\n    if (code) {\n        authOptions.code = code;\n    }\n    oauth(authOptions, function (err, token) {\n        console.log(token);\n    });\n}\n// Test to see if a code is required for a given username and password.\noauth.requiresCode(auth, function (err, hasTwoFactorAuth) {\n    if (!hasTwoFactorAuth) {\n        // No need for a code.\n        getToken();\n    } else {\n        // You need to get a two-factor authentication code from\n        // the user.\n        myCodePrompt(function (err, code) {\n            getToken(code);\n        });\n    }\n});\n```\n\n## Contributing\nIn lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/).\n\n```bash\n# Requirements\nnpm install -g grunt-cli\n# Dev\nnpm install \u0026\u0026 grunt\n```\n\n## Release History\n- `v1.0.1` The Royal Tenenbaums: \"Anybody interested in grabbing a couple of burgers and hittin' the cemetery?\"\n- `v1.0.0` **The Royal Tenenbaums**\n- `v0.2.2` Rushmore: \"What's the secret, Max?\"\n- `v0.2.1` Rushmore: \"I saved Latin. What did you ever do?\"\n- `v0.2.0` **Rushmore**\n- `v0.1.3` Bottle Rocket: \"So, did you enjoy your first visit to the nut house?\n- `v0.1.2` Bottle Rocket: \"Tell Anthony I love him.\"\n- `v0.1.1` Bottle Rocket: \"Which part of Mexico are you from?\"\n- `v0.1.0` **Bottle Rocket**\n\n## License\nCopyright (c) 2014 Henry Blyth. Licensed under the MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhenrahmagix%2Fgithub-oauth-prompt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhenrahmagix%2Fgithub-oauth-prompt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhenrahmagix%2Fgithub-oauth-prompt/lists"}