Skip to content

JSONDecodeError on unauthorized session #997

@st-korn

Description

@st-korn

Sometimes, then we start working with BDFR and we do not have authorized session, we got this error:

  File "C:\Stas\Hobby\bulk-downloader-for-reddit\bdfr\oauth2.py", line 37, in _check_scopes
    known_scopes = [scope for scope, data in response.json().items()]
                                             ^^^^^^^^^^^^^^^
  File "C:\Users\User\AppData\Local\Programs\Python\Python312\Lib\site-packages\requests\models.py", line 980, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)`

This is because the primary api request of scopes https://www.reddit.com/api/v1/scopes.json from bdfr\oauth2.py method OAuth2Authenticator._check_scopes() in unauthorized session return 403 Forbidden page:

Image

I try to fix it and create pull request.

This also leads to issues: #947, #941, #774

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions