Page MenuHomePhabricator

os.environ doesn't get client ID, etc. necessary for PAWS session to use OAuth
Closed, ResolvedPublic

Description

https://www.mediawiki.org/wiki/Manual:Pywikibot/PAWS says running pwb.py at the PAWS command line "should confirm that you can log into https://test.wikipedia.org/ . It uses OAuth, so there is no need to enter a password."

Just now:

Sumanah@PAWS:~$ pwb.py login                                                                                                              
Password for user Sumanah on wikipedia:test (no characters will be shown):                                                                
Logging in to wikipedia:test as Sumanah                                                                                                   
WARNING: API warning (login): Fetching a token via action=login is deprecated. Use action=query&meta=tokens&type=login instead.           
ERROR: Login failed (WrongPass).                                                                                                          
Password for user Sumanah on wikipedia:test (no characters will be shown):

Login depends on OAuth, but even though the user used OAuth to log into PAWS, the os.environ CLIENT_ID, CLIENT_SECRET, ACCESS_KEY, and ACCESS_SECRET aren't being set. So user-config.py can't find them, and the user cannot use Pywikibot to log into a Wikimedia wiki.

Event Timeline

According to the manual: "Pywikibot needs a configuration file 'user-config.py' which PAWS automatically creates for you, with https://test.wikipedia.org/ as the default wiki."

./srv/paws/user-config.py has the following:

import os                                                                                    
                                                                                             
mylang = 'test'                                                                              
family = 'wikipedia'                                                                         
                                                                                             
                                                                                             
custom_path = os.path.expanduser('~/user-config.py')                                         
if os.path.exists(custom_path):                                                              
    with open(custom_path, 'rb') as f:                                                       
        exec(compile(f.read(), custom_path, 'exec'), globals())                              
                                                                                             
    del f                                                                                    
# Clean up temp variables, since pwb issues a warning otherwise                              
# to help people catch misspelt config                                                       
del custom_path                                                                              
                                                                                             
# Things that should be non-easily-overridable                                               
usernames[family]['*'] = os.environ['JPY_USER']                                              
                                                                                             
# If OAuth integration is available, take it                                                 
if 'CLIENT_ID' in os.environ:                                                                
    authenticate['*'] = (                                                                    
        os.environ['CLIENT_ID'],                                                             
        os.environ['CLIENT_SECRET'],                                                         
        os.environ['ACCESS_KEY'],                                                            
        os.environ['ACCESS_SECRET']                                                          
    )
sumanah triaged this task as High priority.Feb 25 2016, 6:21 PM

I am calling this high priority because I know @jayvdb is teaching some workshops in the next few days that will use PAWS, and because this is a showstopper for testing that the user can use pwb to make changes on any wiki at all. May be related to T119933 ?

CLIENT_ID isn't a key set in os.environ, so it can't use OAuth:

>>> for k in os.environ.keys():                                                                                                           
...     print(k)                                                                                                                          
...                                                                                                                                       
KUBERNETES_SERVICE_PORT                                                                                                                   
PWD                                                                                                                                       
KUBERNETES_PORT_443_TCP_PORT                                                                                                              
PATH                                                                                                                                      
JPY_HUB_API_URL                                                                                                                           
KUBERNETES_PORT_443_TCP_PROTO                                                                                                             
SHLVL                                                                                                                                     
USER                                                                                                                                      
KUBERNETES_PORT_443_TCP_ADDR                                                                                                              
JPY_HUB_PREFIX                                                                                                                            
LC_ALL                                                                                                                                    
PAWS_PORT_8000_TCP                                                                                                                        
JPY_COOKIE_NAME                                                                                                                           
HOME                                                                                                                                      
OLDPWD                                                                                                                                    
TERM                                                                                                                                      
_                                                                                                                                         
COLUMNS                                                                                                                                   
KUBERNETES_PORT_443_TCP                                                                                                                   
PAWS_SERVICE_HOST                                                                                                                         
PAWS_PORT_8000_TCP_PROTO                                                                                                                  
JPY_USER                                                                                                                                  
LINES                                                                                                                                     
JPY_BASE_URL                                                                                                                              
KUBERNETES_SERVICE_HOST                                                                                                                   
SHELL                                                                                                                                     
KUBERNETES_PORT                                                                                                                           
PAWS_PORT                                                                                                                                 
PAWS_PORT_8000_TCP_PORT                                                                                                                   
PAWS_PORT_8000_TCP_ADDR                                                                                                                   
PYWIKIBOT2_DIR                                                                                                                            
JUPYTER_SERVER_ROOT                                                                                                                       
PYXTERM_DIMENSIONS                                                                                                                        
HOSTNAME                                                                                                                                  
KUBERNETES_SERVICE_PORT_HTTPS                                                                                                             
PAWS_SERVICE_PORT                                                                                                                         
JUPYTER_SERVER_URL                       
>>>
sumanah renamed this task from "pwb.py login" causes password request to os.environ doesn't get client ID, etc. necessary for PAWS session to use OAuth.Feb 25 2016, 8:42 PM
sumanah updated the task description. (Show Details)
sumanah added a subscriber: yuvipanda.

@jayvdb just said to me:

Isnt PAWS using pywikibot 2.0? Which doesnt support oauth.

I'm not sure what version it's using (and can't check at the moment).

I've identified and fixed the issue! It was due to me using a different version of the MW Authenticator than required. It works now!

Thanks for finding and reporting it!

mylang = 'ja'
family = 'wikipedia'