mnelson4 / printmyblog

WordPress Plugin that simplifies printing your entire blog
GNU General Public License v3.0
16 stars 6 forks source link

Support private blogs (REST API authentication) #255

Open ericjung opened 3 years ago

ericjung commented 3 years ago

Please support private blogs, blogs that require login to view. I understand your plugin calls the WP REST API. Does the WP REST API support HTTP Basic Auth?

mnelson4 commented 3 years ago

Hi @ericjung. The “quick print” tool and front end print buttons can work from a site that requires login because the REST API supports cookie auth. Are you using a plugin to make the site private, or is it server config (eg .htaccess rules)? If you’re just printing for your own record, you can use the “pro print” and print with the browser. If you’d like the print service to work, I can look into adding support for basic auth. Is that something you’re interested in?

mnelson4 commented 3 years ago

Ok I see you provided most of these details on the Wordpress.org forum topic. Ya “quick print” should work but obviously isn’t. Are you able to use the web inspector to view the AJAX response that’s failing (that uses the REST API) on the print page (just before the error message)? That might be helpful.

Pro Print doesn’t use the REST API (too many of these problems) so using it and printing with your browser (not the pro print service yet) should work too.

and FYI you can upload screenshots here on GitHub.

Ok so I’ll wait to hear either more about the error you’re getting with quick print or if pro print with the browser works. If something isn’t clear no worries: just ask and I’ll clarify what I mean.

ericjung commented 3 years ago

Neither. See screenshot here:

image

Anyway, it's working now with the above Privacy Settings set to Private. I don't know why. I've confirmed in a private browsing window that the URL is not accessible without login. It must be using cookie auth, as you suggest, but I don't know why it was broken before.

I'd really like to use the the paid Pro Print Service but my blog is something like 400-500 pages. I read that's not supported. Is that correct? What if I submit 2 different requests, split evenly?

mnelson4 commented 3 years ago

Oh, now it's working? Computers!!!! 😡 But that's good it's working now. I thought it should. It's a mystery why it didn't... it's hard for me to debug as I'm not sure how WordPress.com's "private sites" work under-the-hood (I'm not sure if they're using an open-source plugin or private code) so it's hard for me to investigate further. I'm going to close this issue for now, but please reopen if you have more info or see it happening again.

About Pro: I'd suggest you just start off trying the "Pro Print". Currently, you can try everything for free, just download the Test PDF. I'd suggest you first give that a whirl with, say, a year's worth of posts and see how it works for you. (I wouldn't do more right away because it would take forever: it only supports adding a single item at a time.)

If it works well, then subscribe to https://github.com/mnelson4/printmyblog/issues/106 to see when I make some changes that will make making massive projects much easier. (And if it doesn't work well, please let me know what you liked or didn't or were confused by).

Does that sound good?

ericjung commented 3 years ago

About Pro: I'd suggest you just start off trying the "Pro Print". Currently, you can try everything for free, just download the Test PDF

There's a problem with this:

  1. Click "View Print-Ready PDF Print Page"
  2. Directed to https://someurl/wp-content/uploads/pmb/generated/fukFptUXbQLfJBKTH62E/print_pdf/testing.html?uniqueness=1625586705
  3. I scroll down and see all content correctly, including photos
  4. When I click "Free - Print with Browser", photos are not included in the PDF
  5. When I click "Pro Print Service - Download Test PDF", photos are not included in the PDF
mnelson4 commented 3 years ago

Oh weird- it sounds like something interfering with downloading images but only when printing. I don't have a pro wp.com account to test. It might be best if you could send me temporary access to this site so I can debug this issue. If you're open to that, please use the contact form at https://printmy.blog/contact to get in touch.

mnelson4 commented 3 years ago

Although thinking about it, I think getting Pro to work for private WP sites will probably be tricky. Still, why printing from browser isn't working is extra strange. For my note, if I could pass the current site's cookies to the API I might get this to work: https://www.princexml.com/doc/command-line/.