Search code examples
bashoauth-2.0command-line-interfaceimage-uploadingimgur

A Bash script to upload images to imgur.com automatically asking for new access_token


I was wondering if there's an already written Bash script which will be capable of uploading images to imgur.com along with automating the process of requesting new access token once it expire.

Searching for such a script I found a few which do not support OAuth2:

Quoted from Imgur's OAuth2.0 overview

The Imgur API uses OAuth 2.0 for authentication. OAuth 2.0 has four steps: registration, authorization, making the request, and getting new access_tokens after the initial one expired.

Searching in Imgur's uploading tools I found scripts that do not support OAuth2.0, therefore they are not relevant for my case.

Thank you!


Solution

  • I wrote such a tool a few days ago: rugmi.

    Here are a few usage examples:

    Upload foo.png, bar.png, baz.png and print the result links to stdout.
    $ rugmi -f foo.png -f bar.png -f baz.png
        or
    $ rugmi -- foo.png bar.png baz.png
    
    Upload all JPEG files in a directory and print the result links to stdout.
    $ find dir/ -type f -name '*.jpg' -print0 | rugmi -0
    
    Upload foo.png and print an HTML type of link to be displayed as a medium thumbnail.
    rugmi -f foo.png -t HTML -s MT