Skip to content

AuthenticationError when connecting to Reddit #5659

Description

@kriss6557

Hi,

I’m using gallery-dl within docker and it works perfectly with Pinterest.


I tried to do the same with Reddit, but run into an authentication error.

Here are the steps:
I have a created a script application on reddit (Script for personal use. Will only have access to the developers accounts) called my_appname which provides a client-id and a client-secret.

Then I used a python script which asks Reddit to allow my_appname to

  • Access posts and comments through my account.
  • Maintain this access indefinitely (or until manually revoked).
    Once allowed it sends me back to the redirect URL with a code at the end.
This code ends with some characters (#_) that seems to be excluded to generate the refresh-token
    I add this refresh token to my gallery-dl.conf file below


{
    "extractor": {
        "reddit": {
            "video": true,
            "comments": false,
            "client-id": "qGXXXXXXXXXXXXXX",
            "client-secret": "3XXXXXXXXXXXXXXXXXX",
            "user-agent": "Python:my_appname:v1.0 (by /u/my_username)",
            "refresh-token": "287XXXXXXXXXXXXXXXXXXXXXXXX"
        }
    },
    "output": {
        "mode": "auto",
        "path": "/gallery-dl",
        "progress": true
    },
    "downloader": {
        "http": {
            "rate": "500k",
            "timeout": 30,
            "retries": 4,
            "verify": true
        }
    }
}

Then when running with a URL like https://www.reddit.com/user/my_username/saved I receive:



gallery-dl       | [gallery-dl][debug] Version 1.27.0-dev
gallery-dl       | [gallery-dl][debug] Python 3.12.3 - Linux-5.4.0-172-generic-x86_64-with
gallery-dl       | [gallery-dl][debug] requests 2.32.2 - urllib3 2.2.1
gallery-dl       | [gallery-dl][debug] Configuration Files ['/etc/gallery-dl.conf', '/etc/gallery-dl.conf']
gallery-dl       | [gallery-dl][debug] Starting DownloadJob for 'https://www.reddit.com/user/username/saved'
gallery-dl       | [reddit][debug] Using RedditUserExtractor for 'https://www.reddit.com/user/username/saved'
gallery-dl       | [reddit][debug] Using custom API credentials (client-id qGVzR*****************)
gallery-dl       | [reddit][info] Refreshing private access token
gallery-dl       | [urllib3.connectionpool][debug] Starting new HTTPS connection (1): www.reddit.com:443
gallery-dl       | [urllib3.connectionpool][debug] https://www.reddit.com:443 "POST /api/v1/access_token HTTP/1.1" 401 None
gallery-dl       | [reddit][debug] Server response: {'message': 'Unauthorized', 'error': 401}
gallery-dl       | [reddit][error] AuthenticationError: "401: Unauthorized"
gallery-dl exited with code 16

What am I missing? Can you please help.
Thank you

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions