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

Tie upload to a given account #16

Open
jpmvferreira opened this issue Aug 9, 2019 · 6 comments
Open

Tie upload to a given account #16

jpmvferreira opened this issue Aug 9, 2019 · 6 comments

Comments

@jpmvferreira
Copy link

Hi there,

I was using this tool and it works as expected, did some changes, and realized it would be easier for me if the uploaded content were to be tied to my account.

Using the imgur API i have registered an app, and got my client id, which i changed in the script field default_client_id, however when checking my imgur account the image is not there, and i would like it to.

After reading the imgur API i got a feeling that i required a field named default_client_secret in the script, but there is none and i'm unsure how to do this authentication by myself.

Hopefully i'm not missing anything obvious and bothering you for no relevant reason.

Thanks in advance!

@tremby
Copy link
Owner

tremby commented Aug 9, 2019

I'm afraid I don't personally have any interest in this feature.

Yes, the client ID is just to do with the app. Things uploaded by that app aren't specifically tied to your user account, as you've found.

I had a glance at the docs and it looks like it'd require adding support for OAuth2. That seems like it'd be a little awkward for a CLI program but I'm sure it's possible. I imagine it could work this way:

  1. We check for existing authorization info, which has perhaps been stored in a cache file.
    1. If found
      1. If it's still valid, we use that and exit
      2. Otherwise, if it can still be refreshed, we refresh, then use the new token, and exit
  2. We generate a URL (at Imgur) the user has to go to to authorize.
  3. We start a small localhost webserver to listen for the authorization callback.
  4. We either present the URL to the user or open their browser for them (like with sensible-browser).
  5. The user authorizes.
  6. We have registered the app with a localhost callback URL, so once authorization is finished the browser hits a localhost URL with the response. This is our little server started in step 3.
  7. We store the authorization information
  8. We shut down the web server
  9. We use the auth information and proceed with the request

So... doable, but it'd make the script a whole lot more complicated.

If there's a simpler way than all the above I'll merge a patch for it. But I think any working solution in Bash would have too many dependencies or be too long to be in scope for this script.

@jpmvferreira
Copy link
Author

I've only suggested this feature as i am currently using another piece of software name (imgur-screenshot)[https://github.com/jomo/imgur-screenshot] which features uploading to a given account.

Honestly i have no idea how hard it is to make this work in your script, and i haven't got enough bash skills to try and do it myself, but i think it would be a nice feature to have in your script.

Hopefully the software i sent you changes your mind, or realize it's in fact too complicated to implement.

Thanks anyways!

@tremby
Copy link
Owner

tremby commented Aug 13, 2019

OK, that other script employs an authorization method which doesn't need the callback, which does simplify things significantly. I didn't see that mentioned in the Imgur API documentation but perhaps I overlooked it.

We wouldn't be able to copy the relevant parts of code directly, or I'd have relicence this script under MIT, which I'd rather not do.

But it shows it's possible and not as complicated as I thought, so I'd accept this feature into this script.

I'd accept a patch if someone has the inclination, or I'll do it myself if I do find I want this feature at some point.

For now I'll leave this open. Thanks for pointing out that other script.

@jpmvferreira
Copy link
Author

No problem, always glad to help however i can!

@Darkmaster006
Copy link

Just chiming in and saying I would love for this feature to be available. This script is the simplest one to upload to imgur that I've found and this feature is the only thing missing for me. Either way, thank you.

@takesnodamage
Copy link

+1. I'm trying to upload a list of image links to an imgur album so I have to somehow associate the script with my account. I'll take a look at the jomo script but I'm far from an expert in API stuff so if this option ever did get folded into this code it would be useful.

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

No branches or pull requests

4 participants