@@ -9,6 +9,14 @@ var twoFactorRegex = new RegExp("must specify two-factor authentication otp code
99var badCredentialsRegex = new RegExp ( "bad credentials" , "gi" ) ;
1010
1111var handleBasicAuthentication = function ( username , password , onSuccess , onRequiresTwoFa , onFailure ) {
12+ if ( ! config . clientId || ! config . clientSecret ) {
13+ throw "clientId and/or clientSecret missing" ;
14+ }
15+
16+ if ( ! config . appName ) {
17+ throw "appName missing" ;
18+ }
19+
1220 var octokit = octokitWrapper . createOctokit ( ) ;
1321
1422 octokit . authenticate ( {
@@ -44,6 +52,14 @@ var handleBasicAuthentication = function (username, password, onSuccess, onRequi
4452}
4553
4654var handleTwoFactorAuthentication = function ( username , password , twoFactor , onSuccess , onFailure ) {
55+ if ( ! config . clientId || ! config . clientSecret ) {
56+ throw "clientId and/or clientSecret missing" ;
57+ }
58+
59+ if ( ! config . appName ) {
60+ throw "appName missing" ;
61+ }
62+
4763 var octokit = octokitWrapper . createOctokit ( ) ;
4864
4965 octokit . authenticate ( {
@@ -54,11 +70,11 @@ var handleTwoFactorAuthentication = function (username, password, twoFactor, onS
5470
5571 octokit . authorization . create ( {
5672 scopes : scopes ,
57- note : config . appName ,
5873 client_id : config . clientId ,
5974 client_secret : config . clientSecret ,
6075 headers : {
61- "X-GitHub-OTP" : twoFactor
76+ "X-GitHub-OTP" : twoFactor ,
77+ "user-agent" : config . appName
6278 }
6379 } , function ( err , res ) {
6480 if ( err ) {
0 commit comments