I am using globalusage() in my code on File objects, such as usage = len(list(page.globalusage())). This fails and generates the following NoUsernameError. Noting that the error message made mention of en.wikiquote, I navigated to enwq in my browser while logged in, to automatically create a local account there. Then I reran the code, making no changes, and it ran as expected with no error. I suppose this happens because globalusage wants to create local page objects for all the results in whichever wiki they occur, so you need a local account.
This is overkill for my use case because I just wanted to count them anyway, and didn't need Page objects, but I couldn't find a better way to do it. Maybe PWB needs to create the local user first when you have an SUL account? (Or document that it is necessary and how it is done.) Or provide a method for counting the number without creating page objects, though that's perhaps a separate issue.
@PAWS:~/pageviews$ python generate.py --cat "Category:Media contributed by George W. Bush Presidential Center" Starting data fetch for "Category:Media contributed by George W. Bush Presidential Center". (2023-08-29 20:22:23) WARNING: API error mwoauth-invalid-authorization-invalid-user: The authorization headers in your request are for a user that does not exist here Traceback (most recent call last): File "/home/paws/pageviews/generate.py", line 134, in <module> cat(args.cat) File "/home/paws/pageviews/generate.py", line 75, in cat usage = len(list(page.globalusage())) File "/srv/paws/lib/python3.10/site-packages/pywikibot/site/_extensions.py", line 224, in globalusage gu_site = pywikibot.Site(url=entry['url']) File "/srv/paws/lib/python3.10/site-packages/pywikibot/__init__.py", line 206, in Site code, fam = _code_fam_from_url(url, fam) File "/srv/paws/lib/python3.10/site-packages/pywikibot/__init__.py", line 117, in _code_fam_from_url code = family.from_url(url) File "/srv/paws/lib/python3.10/site-packages/pywikibot/family.py", line 608, in from_url site = pywikibot.Site(code, self.name) File "/srv/paws/lib/python3.10/site-packages/pywikibot/__init__.py", line 253, in Site _sites[key] = interface(code=code, fam=fam, user=user) File "/srv/paws/lib/python3.10/site-packages/pywikibot/site/_apisite.py", line 127, in __init__ self.login(cookie_only=True) File "/srv/paws/lib/python3.10/site-packages/pywikibot/site/_apisite.py", line 387, in login raise e File "/srv/paws/lib/python3.10/site-packages/pywikibot/site/_apisite.py", line 378, in login if self.userinfo['name'] == self.user(): File "/srv/paws/lib/python3.10/site-packages/pywikibot/site/_apisite.py", line 536, in userinfo uidata = uirequest.submit() File "/srv/paws/lib/python3.10/site-packages/pywikibot/data/api/_requests.py", line 974, in submit self._add_defaults() File "/srv/paws/lib/python3.10/site-packages/pywikibot/data/api/_requests.py", line 442, in _add_defaults and self.site.mw_version >= '1.25wmf5'): File "/srv/paws/lib/python3.10/site-packages/pywikibot/site/_apisite.py", line 1148, in mw_version mw_ver = MediaWikiVersion(self.version()) File "/srv/paws/lib/python3.10/site-packages/pywikibot/site/_apisite.py", line 1121, in version version = self.siteinfo.get('generator', expiry=1).split(' ')[1] File "/srv/paws/lib/python3.10/site-packages/pywikibot/site/_siteinfo.py", line 304, in get preloaded = self._get_general(key, expiry) File "/srv/paws/lib/python3.10/site-packages/pywikibot/site/_siteinfo.py", line 242, in _get_general default_info = self._get_siteinfo(props, expiry) File "/srv/paws/lib/python3.10/site-packages/pywikibot/site/_siteinfo.py", line 167, in _get_siteinfo data = request.submit() File "/srv/paws/lib/python3.10/site-packages/pywikibot/data/api/_requests.py", line 1282, in submit self._data = super().submit() File "/srv/paws/lib/python3.10/site-packages/pywikibot/data/api/_requests.py", line 1079, in submit raise NoUsernameError(f'Failed {msg}') pywikibot.exceptions.NoUsernameError: Failed OAuth authentication for wikiquote:en: The authorization headers in your request are for a user that does not exist here CRITICAL: Exiting due to uncaught exception NoUsernameError: Failed OAuth authentication for wikiquote:en: The authorization headers in your request are for a user that does not exist here