maxlath / wikibase-cli

read and edit a Wikibase instance from the command line
MIT License
226 stars 24 forks source link

Logging in on a custom instance does not work and is rate limited #50

Closed almereyda closed 6 years ago

almereyda commented 6 years ago

When using our custom instance, a working combination of username and password cannot login:

wikidata-cli set-label Q223 sk "Rodová rovnosť"                                                                                                                
{ Error: login error                                                                                                                                           
    at breq.post.then.res (/home/ya/.nvm/versions/node/v8.9.4/lib/node_modules/wikidata-cli/node_modules/wikidata-token/lib/login.js:56:21)                    
    at tryCatcher (/home/ya/.nvm/versions/node/v8.9.4/lib/node_modules/wikidata-cli/node_modules/bluebird/js/release/util.js:16:23)                            
    at Promise._settlePromiseFromHandler (/home/ya/.nvm/versions/node/v8.9.4/lib/node_modules/wikidata-cli/node_modules/bluebird/js/release/promise.js:512:31) 
    at Promise._settlePromise (/home/ya/.nvm/versions/node/v8.9.4/lib/node_modules/wikidata-cli/node_modules/bluebird/js/release/promise.js:569:18)            
    at Promise._settlePromise0 (/home/ya/.nvm/versions/node/v8.9.4/lib/node_modules/wikidata-cli/node_modules/bluebird/js/release/promise.js:614:10)           
    at Promise._settlePromises (/home/ya/.nvm/versions/node/v8.9.4/lib/node_modules/wikidata-cli/node_modules/bluebird/js/release/promise.js:693:18)           
    at Async._drainQueue (/home/ya/.nvm/versions/node/v8.9.4/lib/node_modules/wikidata-cli/node_modules/bluebird/js/release/async.js:133:16)                   
    at Async._drainQueues (/home/ya/.nvm/versions/node/v8.9.4/lib/node_modules/wikidata-cli/node_modules/bluebird/js/release/async.js:143:10)                  
    at Immediate.Async.drainQueues (/home/ya/.nvm/versions/node/v8.9.4/lib/node_modules/wikidata-cli/node_modules/bluebird/js/release/async.js:17:14)          
    at runCallback (timers.js:789:20)                                                                                                                          
    at tryOnImmediate (timers.js:751:5)                                                                                                                        
    at processImmediate [as _immediateCallback] (timers.js:722:5)                                                                                              
  statusCode: 200,                                                                                                                                             
  body:                                                                                                                                                        
   { login:                                                                                                                                                    
      { result: 'Failed',                                                                                                                                      
        reason: 'Incorrect username or password entered. Please try again.' } } }                                                                              
wikidata-cli set-label Q224 sk "Čistá voda a hygiena"                                                                                                          
{ Error: login error                                                                                                                                           
    at breq.post.then.res (/home/ya/.nvm/versions/node/v8.9.4/lib/node_modules/wikidata-cli/node_modules/wikidata-token/lib/login.js:56:21)                    
    at tryCatcher (/home/ya/.nvm/versions/node/v8.9.4/lib/node_modules/wikidata-cli/node_modules/bluebird/js/release/util.js:16:23)                            
    at Promise._settlePromiseFromHandler (/home/ya/.nvm/versions/node/v8.9.4/lib/node_modules/wikidata-cli/node_modules/bluebird/js/release/promise.js:512:31) 
    at Promise._settlePromise (/home/ya/.nvm/versions/node/v8.9.4/lib/node_modules/wikidata-cli/node_modules/bluebird/js/release/promise.js:569:18)            
    at Promise._settlePromise0 (/home/ya/.nvm/versions/node/v8.9.4/lib/node_modules/wikidata-cli/node_modules/bluebird/js/release/promise.js:614:10)           
    at Promise._settlePromises (/home/ya/.nvm/versions/node/v8.9.4/lib/node_modules/wikidata-cli/node_modules/bluebird/js/release/promise.js:693:18)           
    at Async._drainQueue (/home/ya/.nvm/versions/node/v8.9.4/lib/node_modules/wikidata-cli/node_modules/bluebird/js/release/async.js:133:16)                   
    at Async._drainQueues (/home/ya/.nvm/versions/node/v8.9.4/lib/node_modules/wikidata-cli/node_modules/bluebird/js/release/async.js:143:10)                  
    at Immediate.Async.drainQueues (/home/ya/.nvm/versions/node/v8.9.4/lib/node_modules/wikidata-cli/node_modules/bluebird/js/release/async.js:17:14)          
    at runCallback (timers.js:789:20)                                                                                                                          
    at tryOnImmediate (timers.js:751:5)                                                                                                                        
    at processImmediate [as _immediateCallback] (timers.js:722:5)                                                                                              
  statusCode: 200,                                                                                                                                             
  body:                                                                                                                                                        
   { login:                                                                                                                                                    
      { result: 'Failed',                                                                                                                                      
        reason: 'You have made too many recent login attempts. Please wait 5 minutes before trying again.' } } }                                               
almereyda commented 6 years ago

I guess https://github.com/maxlath/wikidata-cli/blob/master/lib/edit/init_credentials.js#L28 does not pass the instance variable set in the config to wikibaseInstance of wikidata-token.

This will be useful for https://hack.allmende.io/s/transformaps-20171205-sustainable-development-goals#automatisierung

maxlath commented 6 years ago

do you see anything detail in your wikibase instance logs that could help identify what's wrong?

almereyda commented 6 years ago

No, our instance is not called at all, as it is not passed to the function which generates the access token.

maxlath commented 6 years ago

Indeed the problem was that both init_credentials and edit_command were ignoring custom instances: 6a22692 (published in v6.0.2) should fix that, can you confirm?

almereyda commented 6 years ago

I can currently not verify this due to https://github.com/maxlath/wikidata-cli/issues/49#issuecomment-358125745

almereyda commented 6 years ago

Confirmed working as of https://github.com/maxlath/wikidata-cli/issues/49#issuecomment-358674372