Skip to content

urllib.error.HTTPError: HTTP Error 401: Unauthorized #96

@EssenSea

Description

@EssenSea

use oauth2.py to generate and authorize an OAuth2 token

the client type is web application(what wiki metioned 'installed application' is not found in generated progress).

After 'Enter verification code', something not work as desire, see bellow:

Traceback (most recent call last):
  File "/home/moonsea/.cache/oauth/oauth2.py", line 354, in <module>
    main(sys.argv)
    ~~~~^^^^^^^^^^
  File "/home/moonsea/.cache/oauth/oauth2.py", line 332, in main
    response = AuthorizeTokens(options.client_id, options.client_secret,
                                authorization_code)
  File "/home/moonsea/.cache/oauth/oauth2.py", line 224, in AuthorizeTokens
    response = urllib.request.urlopen(request_url, urllib.parse.urlencode(params).encode('utf-8')).read()
               ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/urllib/request.py", line 189, in urlopen
    return opener.open(url, data, timeout)
           ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/urllib/request.py", line 495, in open
    response = meth(req, response)
  File "/usr/lib/python3.13/urllib/request.py", line 604, in http_response
    response = self.parent.error(
        'http', request, response, code, msg, hdrs)
  File "/usr/lib/python3.13/urllib/request.py", line 533, in error
    return self._call_chain(*args)
           ~~~~~~~~~~~~~~~~^^^^^^^
  File "/usr/lib/python3.13/urllib/request.py", line 466, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.13/urllib/request.py", line 613, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 401: Unauthorized

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions