FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
nodegit/examples/cloneFromGithubWith2Factor.js at master · nodegit/nodegit · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
nodegit
/
nodegit
Public
Notifications
You must be signed in to change notification settings
Fork
700
Star
5.8k
Code
Issues
343
Pull requests
20
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
nodegit
/
examples
/
cloneFromGithubWith2Factor.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
39 lines (34 loc) · 1.1 KB
Breadcrumbs
nodegit
/
examples
/
cloneFromGithubWith2Factor.js
Copy path
File metadata and controls
39 lines (34 loc) · 1.1 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
var
nodegit
=
require
(
"../"
)
;
var
fse
=
require
(
"fs-extra"
)
;
var
path
=
"/tmp/nodegit-github-2factor-demo"
;
var
token
=
"{Your GitHub user token}"
;
var
repoOwner
=
"{The orgname or username that owns the repo}"
;
var
repoName
=
"{The name of the repo}"
;
// To clone with 2 factor auth enabled, you have to use a github oauth token
// over https, it can't be done with actual 2 factor.
// https://github.com/blog/1270-easier-builds-and-deployments-using-git-over-https-and-oauth
// If the repo is public, you can use a callback instead
var
repoUrl
=
"https://github.com/"
+
repoOwner
+
"/"
+
repoName
+
".git"
;
var
opts
=
{
fetchOpts
:
{
callbacks
:
{
credentials
:
function
(
)
{
return
nodegit
.
Cred
.
userpassPlaintextNew
(
token
,
"x-oauth-basic"
)
;
}
,
certificateCheck
:
function
(
)
{
return
0
;
}
}
}
}
;
fse
.
remove
(
path
)
.
then
(
function
(
)
{
nodegit
.
Clone
(
repoUrl
,
path
,
opts
)
.
done
(
function
(
repo
)
{
if
(
repo
instanceof
nodegit
.
Repository
)
{
console
.
info
(
"We cloned the repo!"
)
;
}
else
{
console
.
error
(
"Something borked :("
)
;
}
}
)
;
}
)
;
Back
|
FazBrowse Home
|
New Git URL