Sample for GitHub OAuth API.
-
Create Github account
-
Create a repository which is supposed to be handled by this application.
-
Create repository.
-
Make main branch name as "main".
-
Add, commit, and push at least one file into this main branch.
-
-
If you want to make this repository to be used by another GitHub user, you need to add him/her as Collaborator in this repository.
-
Sign-in to GitHub : https://github.com/
-
Navigate from upper-right menu: Settings - Developer settings - OAuth Apps - New GitHub App
-
Input App name, Homepage URL(
http://localhost:8080
for example), Callback URL(http://localhost:8080/api/callback
for example), and click Create GitHub App button. -
Copy
client_id
, (generated)client_secret
, andcallback_url
, then paste them into settings.js. -
Edit
repo_name
in settings.js. This value is supposed to be a same name of repository which is created in above.- If your Github username is
USER
and repository name isREPO
, then this value should be set asUSER/REPO
.
- If your Github username is
-
Edit
target_branch_name
in settings.js, if needed. This value is a branch name of repository which is supposed to be created in initial setup and to be merged into.
-
Install Node.js
-
Git clone or Download this code:
-
$ git clone https://github.com/dotnsf/githubapi
-
$ cd githubapi
-
-
Install dependant libraries:
$ npm install
-
Run application:
$ node app
-
Browse application with web browser:
https://docs.github.com/en/developers/apps/building-oauth-apps
https://docs.github.com/en/rest
https://qiita.com/ngs/items/34e51186a485c705ffdb
This code islicensed under MIT.
2021 K.Kimura @ Juge.Me all rights reserved.