Creating a OauthLoginManager directly isn't working.

site = Site('wikipedia:test', user='RoySmith')
manager = OauthLoginManager(consumer_secret, site, consumer_token)

with PYWIKIBOT_NO_USER_CONFIG=1

gets me

user-config.py cannot be loaded.
family and mylang are not set.
Defaulting to family='wikipedia' and mylang='test'.
Traceback (most recent call last):
  File "/Users/roy/dev/dyk-tools/venv/lib/python3.9/site-packages/pywikibot/login.py", line 99, in __init__
    user = code_to_usr.get(site.code) or code_to_usr['*']
KeyError: '*'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/roy/temp/bot.py", line 13, in <module>
    manager = OauthLoginManager(consumer_secret, site, consumer_token)
  File "/Users/roy/dev/dyk-tools/venv/lib/python3.9/site-packages/pywikibot/login.py", line 373, in __init__
    super().__init__(password=None, site=site, user=None)
  File "/Users/roy/dev/dyk-tools/venv/lib/python3.9/site-packages/pywikibot/login.py", line 101, in __init__
    raise NoUsernameError(
pywikibot.exceptions.NoUsernameError: ERROR: username for wikipedia:test is undefined.
If you have a username for that site, please add a line to user config file (user_config.py) as follows:
usernames['wikipedia']['test'] = 'myUsername'
CRITICAL: Exiting due to uncaught exception <class 'pywikibot.exceptions.NoUsernameError'>



On Feb 23, 2023, at 6:42 PM, Roy Smith <roy@panix.com> wrote:

I thinking maybe I want to use PYWIKIBOT_NO_USER_CONFIG=2 and ignore the user-config.py stuff completely, but it's not clear how I pass the config into the library.  Family and mylang are easy; I just pass those directly to pywikibot.Site().  But It's not clear what to do with username and the OAuth credentials that are currently in authenticate[].  Do I just create a login.OauthLoginManager and call login() on that?