Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: really support not receiving refresh token #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AdamWill
Copy link

The previous attempt would still crash if the key was not in the
dict at all (as seems to be the case with recent mediawiki), so
we need to handle that too.

Signed-off-by: Adam Williamson awilliam@redhat.com

The previous attempt would still crash if the key was not in the
dict at all (as seems to be the case with recent mediawiki), so
we need to handle that too.

Signed-off-by: Adam Williamson <awilliam@redhat.com>
@AdamWill
Copy link
Author

hmm, still not sure this is the whole story. after applying this patch, instead of crashing because refresh_token isn't a key in the dict at all, we now wind up tracing back because we're unauthorized, seemingly after refreshing fails. On one instance we get this, with an "invalid_grant" error:

DEBUG:openidc_client:Unable to refresh, error: invalid_grant
DEBUG:openidc_client:Removing token 90xxxxxxxx37 from cache
DEBUG:openidc_client:Refreshing cache
DEBUG:openidc_client:Loaded 1 tokens
DEBUG:openidc_client:Removing token
DEBUG:openidc_client:Writing cache with 0 tokens
Traceback (most recent call last):
  File "/usr/local/bin/fedora-openqa", line 33, in <module>
    sys.exit(load_entry_point('fedora-openqa==3.1.0', 'console_scripts', 'fedora-openqa')())
  File "/usr/local/lib/python3.10/site-packages/fedora_openqa-3.1.0-py3.10.egg/fedora_openqa/cli.py", line 277, in main
  File "/usr/local/lib/python3.10/site-packages/fedora_openqa-3.1.0-py3.10.egg/fedora_openqa/cli.py", line 166, in run
  File "/usr/local/lib/python3.10/site-packages/fedora_openqa-3.1.0-py3.10.egg/fedora_openqa/cli.py", line 127, in command_report
  File "/usr/local/lib/python3.10/site-packages/fedora_openqa-3.1.0-py3.10.egg/fedora_openqa/report.py", line 322, in wiki_report
  File "/usr/lib/python3.10/site-packages/wikitcms/wiki.py", line 338, in login
    self.site_init()
  File "/usr/lib/python3.10/site-packages/mwclient/client.py", line 142, in site_init
    info = self.get('query', meta='userinfo', uiprop='groups|rights')
  File "/usr/lib/python3.10/site-packages/mwclient/client.py", line 234, in get
    return self.api(action, 'GET', *args, **kwargs)
  File "/usr/lib/python3.10/site-packages/mwclient/client.py", line 285, in api
    info = self.raw_api(action, http_method, **kwargs)
  File "/usr/lib/python3.10/site-packages/mwclient/client.py", line 437, in raw_api
    res = self.raw_call('api', data, retry_on_error=retry_on_error,
  File "/usr/lib/python3.10/site-packages/mwclient/client.py", line 409, in raw_call
    stream.raise_for_status()
  File "/usr/lib/python3.10/site-packages/requests/models.py", line 960, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://stg.fedoraproject.org/w/api.php?meta=userinfo%7Cuserinfo&uiprop=groups%7Crights%7Cblockinfo%7Chasmsg&continue=&action=query&format=json

on the other we get the "no refresh token present" debug line and then a similar traceback:

DEBUG:openidc_client:Unable to refresh: no refresh token present
DEBUG:openidc_client:Removing token edfxxxxxxx32 from cache
DEBUG:openidc_client:Refreshing cache
DEBUG:openidc_client:Loaded 1 tokens
DEBUG:openidc_client:Removing token
DEBUG:openidc_client:Writing cache with 0 tokens
Traceback (most recent call last):
  File "/usr/local/bin/fedora-openqa", line 33, in <module>
    sys.exit(load_entry_point('fedora-openqa==3.1.0', 'console_scripts', 'fedora-openqa')())
  File "/usr/local/lib/python3.10/site-packages/fedora_openqa-3.1.0-py3.10.egg/fedora_openqa/cli.py", line 277, in main
  File "/usr/local/lib/python3.10/site-packages/fedora_openqa-3.1.0-py3.10.egg/fedora_openqa/cli.py", line 166, in run
  File "/usr/local/lib/python3.10/site-packages/fedora_openqa-3.1.0-py3.10.egg/fedora_openqa/cli.py", line 127, in command_report
  File "/usr/local/lib/python3.10/site-packages/fedora_openqa-3.1.0-py3.10.egg/fedora_openqa/report.py", line 330, in wiki_report
  File "/usr/lib/python3.10/site-packages/wikitcms/wiki.py", line 716, in report_validation_results
    pagedict[key] = (self.get_validation_page(*key), dict())
  File "/usr/lib/python3.10/site-packages/wikitcms/wiki.py", line 579, in get_validation_page
    return wikitcms.page.NightlyPage(
  File "/usr/lib/python3.10/site-packages/wikitcms/page.py", line 469, in __init__
    super(NightlyPage, self).__init__(
  File "/usr/lib/python3.10/site-packages/wikitcms/page.py", line 181, in __init__
    super(ValidationPage, self).__init__(site, wikiname, info)
  File "/usr/lib/python3.10/site-packages/wikitcms/page.py", line 53, in __init__
    super(Page, self).__init__(site, wikiname, info, extra_properties)
  File "/usr/lib/python3.10/site-packages/mwclient/page.py", line 33, in __init__
    info = self.site.get('query', prop=prop, titles=name,
  File "/usr/lib/python3.10/site-packages/mwclient/client.py", line 234, in get
    return self.api(action, 'GET', *args, **kwargs)
  File "/usr/lib/python3.10/site-packages/mwclient/client.py", line 285, in api
    info = self.raw_api(action, http_method, **kwargs)
  File "/usr/lib/python3.10/site-packages/mwclient/client.py", line 437, in raw_api
    res = self.raw_call('api', data, retry_on_error=retry_on_error,
  File "/usr/lib/python3.10/site-packages/mwclient/client.py", line 409, in raw_call
    stream.raise_for_status()
  File "/usr/lib/python3.10/site-packages/requests/models.py", line 960, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://fedoraproject.org/w/api.php?prop=info&titles=Test+Results%3AFedora+37+Rawhide+20220615.n.0+Installation&inprop=protection&continue=&meta=userinfo&uiprop=blockinfo%7Chasmsg&action=query&format=json

don't have time to dig further into it today, just mentioning it here so I don't forget about it...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant