bbolli / tumblr-utils

Utilities for dealing with Tumblr blogs, Tumblr backup
GNU General Public License v3.0
667 stars 124 forks source link

HTTP Error 401: Unauthorized getting https://api.tumblr.com/ #210

Closed jorong1 closed 4 years ago

jorong1 commented 4 years ago

tumblr-utils 08cbe44 Command: ./bin/python2.7 tumblr_backup.py --incremental --save-video --save-audio --json $BLOG

Output:

HTTP Error 401: Unauthorized getting https://api.tumblr.com/v2/blog/$BLOG.tumblr.com/posts?reblog_info=true&api_key=brVeh51SIEuLgQIJqRwmJYJMNdXHSvk0R3GiN0ETcaDYrEqH1B&limit=1

Expected output: Posts successfully being backed up

This happens on any blog, any post. Confirmed the blogs are not private, do exist, and don't require you to be logged in to Tumblr to view. Is this because the API key was update recently and it's hit the 5000 API call limit, before Tumblr has approved limit removal?

Also begs the question, if I use my own app and API key can I avoid this error? Thanks

ghost commented 4 years ago

I've got the same issue. I already had it yesterday, then downloaded the recently updated tumblr_backup.py with the new API key and everything worked, but apparently Tumblr has changed something between yesterday and today...

bbolli commented 4 years ago

I didn't apply for any rate limitation. But if this goes on, I'll have to remove the API key and you mass-downloaders will have to get your own keys :-)

daggerfang1 commented 4 years ago

I didn't apply for any rate limitation. But if this goes on, I'll have to remove the API key and you mass-downloaders will have to get your own keys :-)

I'm having the same issue. My last attempt before today was April 29 and there was no problem. Now I can't do anything.

I'm willing to get my own API key - how do I do that? I looked at my account settings on tumblr and it isn't obvious where to get one. And once I do that, do I just replace the key currently in your .py file with the new one?

ghost commented 4 years ago

I'm willing to get my own API key - how do I do that? I looked at my account settings on tumblr and it isn't obvious where to get one. And once I do that, do I just replace the key currently in your .py file with the new one?

As far as I understand it, you can't just get the API key, you need to register an application that you would need the key for: https://www.tumblr.com/oauth/register Otherwise I would also love to get my own key. PS: I'm not a mass-downloader, I just like to save my Tumblr content every couple of months.

Loreweaver15 commented 4 years ago

5000 requests per day is one thing, but the process doesn't even start for me--I just get the "Unauthorized getting" error a dozen times when I try to run it and then it stops.

jorong1 commented 4 years ago

PS: I'm not a mass-downloader, I just like to save my Tumblr content every couple of months.

Same with me. What I'm confused is how the script worked previously for so long, with the old API key, for so many people and blog archives, rate limitation exception? I ran this script on tons of blogs in the past.

It sounds like we should be making our own oath app and getting our own oath API consumer key (which I've now done and the script works again) so we could at least do 5000 requests a day individually.

I think this issue could be closed assuming this requirement is stated in the README now, or if @bbolli applies for rate exception for the new key.

5000 requests per day is one thing, but the process doesn't even start for me--I just get the "Unauthorized getting" error a dozen times when I try to run it and then it stops.

This is because the new API key is restricted to 5000 requests a day and has hit that limit, given it's public. See above posts, you need to make your own oAuth app and replace the API key in the tumblr_backup.py script with it.

https://www.tumblr.com/oauth/register

ghost commented 4 years ago

It sounds like we should be making our own oath app and getting our own oath API consumer key (which I've now done and the script works again) so we could at least do 5000 requests a day individually.

I don't even have the first clue how to build my own oath app - is there any way you could help me with that?

slowcar commented 4 years ago

To get an API key log in to Tumblr and go to https://www.tumblr.com/oauth/apps Enter stuff into the fields marked with an asterisk. We just wrote "backup tumblr posts" into the description. The whole process is automated, afaik there is no human interaction whatsoever, but as it is connected to your account you should probably stay civil. Click two buttons, you get your API_KEY. Open the backup.py from these tools, look for API_KEY and replace the existing with your new one.

ghost commented 4 years ago

To get an API key log in to Tumblr and go to https://www.tumblr.com/oauth/apps Enter stuff into the fields marked with an asterisk. We just wrote "backup tumblr posts" into the description. The whole process is automated, afaik there is no human interaction whatsoever, but as it is connected to your account you should probably stay civil. Click two buttons, you get your API_KEY. Open the backup.py from these tools, look for API_KEY and replace the existing with your new one.

Thank you so much, that works! Somehow I thought someone was gonna check on my (non-existent) application and website before I got the key...

cyle commented 4 years ago

Hey folks, random Tumblr engineer here! Please do not include Tumblr API keys in public repos! As stated in the API agreement, sharing your API key is not allowed. Instead, please set up your own API key for what you want to do, as has been described already in this thread. That's the best path forward for tools like this.

daggerfang1 commented 4 years ago

To get an API key log in to Tumblr and go to https://www.tumblr.com/oauth/apps Enter stuff into the fields marked with an asterisk. We just wrote "backup tumblr posts" into the description. The whole process is automated, afaik there is no human interaction whatsoever, but as it is connected to your account you should probably stay civil. Click two buttons, you get your API_KEY. Open the backup.py from these tools, look for API_KEY and replace the existing with your new one.

wonder if they closed that loophole already. I'm trying to do the same thing and it's not accepting any of the application website and callback urls I am entering. I've tried both fake and actual websites.

slowcar commented 4 years ago

It's not a loophole, it's the official way to interact with the Tumblr API. The URL values are checked for validity with a regular expression or something like that, make sure to have http or https in them. for the application url I used the Tumblr blog url, callback url is not really needed unless you have authentication, I put http://localhost:3000 in there.

daggerfang1 commented 4 years ago

It's not a loophole, it's the official way to interact with the Tumblr API. The URL values are checked for validity with a regular expression or something like that, make sure to have http or https in them. for the application url I used the Tumblr blog url, callback url is not really needed unless you have authentication, I put http://localhost:3000 in there.

putting localhost for the callback worked. thanks.