davesteele / cloudprint-service

Debian packaging for the Python cloudprint proxy utility
GNU General Public License v3.0
71 stars 4 forks source link

REST Error:404 Message: https://developers.google.com/accounts/docs/AuthForInstalledApps #24

Closed hubertbanas closed 9 years ago

hubertbanas commented 9 years ago

It just stopped working today (2015/05/27). Here is the error message:

sudo service cloudprintd start

Traceback (most recent call last):
  File "/usr/sbin/cloudprintd", line 9, in <module>
    load_entry_point('cloudprint==0.11', 'console_scripts', 'cloudprint-cmd')()
  File "/usr/share/cloudprint/cloudprint/cloudprint.py", line 510, in main
    sync_printers(cups_connection, cpp)
  File "/usr/share/cloudprint/cloudprint/cloudprint.py", line 334, in sync_printers
    remote_printers = dict([(p.name, p) for p in cpp.get_printers()])
  File "/usr/share/cloudprint/cloudprint/cloudprint.py", line 181, in get_printers
    r = self.get_rest()
  File "/usr/share/cloudprint/cloudprint/cloudprint.py", line 177, in get_rest
    auth = self.get_auth()
  File "/usr/share/cloudprint/cloudprint/cloudprint.py", line 103, in get_auth
    'application/x-www-form-urlencoded')
  File "/usr/share/cloudprint/cloudprint/rest.py", line 122, in post
    return self.rest_call('POST', path, data, content_type, headers, response_type)
  File "/usr/share/cloudprint/cloudprint/rest.py", line 105, in rest_call
    raise REST.RESTException('REST Error', resp.status, data)
cloudprint.rest.RESTException: REST Error:404
Message: https://developers.google.com/accounts/docs/AuthForInstalledApps

I'm able to login to the google account with no problems. All of my printers are there but for some unknown reason cloudprint just stopped working. I'm seeing the same problem on two different Debian Wheezy systems located in two different physical locations. Both were working fine for a very long time. No configuration changes on my end.

According to the link:

Important: ClientLogin has been officially deprecated since April 20, 2012 and is now no longer available. Requests to ClientLogin will fail with a HTTP 404 response. We encourage you to migrate to OAuth 2.0 as soon as possible.

akabakass commented 9 years ago

confirmed, same for me

motorkap commented 9 years ago

Me too, looks like Google broke this software. Are there any plans to 'migrate to OAuth 2.0'?

davesteele commented 9 years ago

Are there any plans to 'migrate to OAuth 2.0'?

Yes. I have an OAuth2 solution, and will migrate it to cloudprint-service.

Google announced this change, and we are passed the deadline they set.

----------------------Edit May 2016 ------------------------- OAuth2-compatible versions are available at http://davesteele.github.io/cloudprint-service/.

motorkap commented 9 years ago

Thanks Dave, a fix would be much appreciated.

tylla commented 9 years ago

A fix would be awesome. Can we help with anything? Testing etc.?

bmccarthy commented 9 years ago

Thanks for this software. I would like to use this software for an event this upcoming week. Any chance the fix will be put in in the next couple days? I can help with testing if you need it.

davesteele commented 9 years ago

Can we help with anything? Testing etc.?

Test 0.11-7 on the website.

It's been put together quickly, and I found I had to implement systemd support to get it to work. Check out the new man pages.

You can fall back to just cloudprint if there are problems with the service.

motorkap commented 9 years ago

Hi Dave, I'm struggling a bit to work out what I need to do. This is what I did so far on my headless raspberry pi: (apt-get update) Preparing to replace cloudprint-service 0.11-5.1 (using .../cloudprint-service_0.11-7_all.deb) ... Unpacking replacement cloudprint-service ... Processing triggers for man-db ... locale: Cannot set LC_ALL to default locale: No such file or directory Setting up cloudprint-service (0.11-7) ... pi@SqueezePi ~ $ service cloudprintd status [FAIL] cloudprint is not running ... failed! (as expected) pi@SqueezePi ~ $ service cloudprintd start No authentication found - run 'service cloudprintd login' as root

(running this gives the same error as before, so I went back and ready your post again and decided I need to RTFM)

pi@SqueezePi ~ $ man cloudprint-service

(from this I learn that I probably need to set some credentials up using cps-auth, but that doesn't work as it tries to start a browser in the UI. However, my Pi is headless so that doesn't work. Then I discover that you have even thought of that and I need to run cloudprint-auth. Tried that, command not found. Had a look for /var/lib/cloudprint/authfile, but no cloudprint directory (only /var/lib/cloudprintd. Decided to install cloudprint).

pi@SqueezePi ~ $ sudo pip install cloudprint Downloading/unpacking cloudprint Running setup.py egg_info for package cloudprint

Installing collected packages: cloudprint Running setup.py install for cloudprint

Installing cloudprint script to /usr/local/bin

Successfully installed cloudprint Cleaning up...

Still no cloudprint-auth command. What now, where did I go wrong?

davesteele commented 9 years ago

My OAuth2 implementation needs a graphical browser environment to get the credentials. Here's what to do:

From a computer with a desktop, run cloudprint -c to establish credentials. Copy the resulting ~/.cloudprint.auth to the actual server. (if the login doesn't prompt you, delete the file to 'logout'). The destination file is /var/lib/cloudprint/authfile.

Cloudprint-service requires systemd now. If that is too much of a headache, you can run cloudprint bare (e.g. cloudprint -d) till things settle down.

bmccarthy commented 9 years ago

I get the below error message when attempting to install on a new raspberry pi 2 B. Not sure if it is related to any changes made.

pi@raspberrypi ~ $ sudo apt-get install cloudprint cloudprint-service Reading package lists... Done Building dependency tree
Reading state information... Done Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation:

The following packages have unmet dependencies: cloudprint : Depends: python:any (>= 2.7) but it is not installable E: Unable to correct problems, you have held broken packages.

redstar3894 commented 9 years ago

@bmccarthy You need to upgrade to Raspbian Jessie in order to install the update currently, raspbian wheezy doesn't have the correct python version.

@davesteele I was able to install the packages using a raspberry pi, but cloudprint-auth fails when using X forwarded over SSH and still doesn't recognize a graphical environment

pi@archangel ~ $ cps-auth **** non-network local connections being added to access control list Graphical environment needed for OAuth2 login pi@archangel ~ $ cloudprint-auth ***** Traceback (most recent call last): File "/usr/bin/cloudprint-auth", line 9, in load_entry_point('cloudprint==0.11', 'console_scripts', 'cloudprint-auth')() File "/usr/share/cloudprint/cloudprint/cpoauth.py", line 166, in main access, refresh = oauth.generate_tokens(login) File "/usr/share/cloudprint/cloudprint/cpoauth.py", line 137, in generate_tokens code = self.get_code(login) File "/usr/share/cloudprint/cloudprint/cpoauth.py", line 56, in get_code GLib.threads_init() NameError: global name 'GLib' is not defined

I've been looking around, and it doesn't look like there's a python-glib package I'm missing, but I'm not sure what else might be happening?

akabakass commented 9 years ago

hi, i also having som issues installing: when trying apt-get install cloudprint-service i get: cloudprint-service : Depends: init-system-helpers (>= 1.18~) but it is not installable and i'm not able to manage to install it, so i tried cloudprint, but when i try something (like cloudprint -c or whatever else), i get: Traceback (most recent call last): File "/usr/bin/cloudprint", line 9, in load_entry_point('cloudprint==0.11', 'console_scripts', 'cloudprint-cmd')() File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 337, in load_entry_point return get_distribution(dist).load_entry_point(group, name) File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2279, in load_entry_point return ep.load() File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1989, in load entry = import(self.module_name, globals(),globals(), ['name']) File "/usr/share/cloudprint/cloudprint/cloudprint.py", line 38, in import cpoauth File "/usr/share/cloudprint/cloudprint/cpoauth.py", line 16, in from gi.repository import Gtk File "/usr/lib/python2.7/dist-packages/gi/importer.py", line 76, in load_module dynamic_module._load() File "/usr/lib/python2.7/dist-packages/gi/module.py", line 224, in _load overrides_modules = import('gi.overrides', fromlist=[self._namespace]) File "/usr/lib/python2.7/dist-packages/gi/overrides/Gtk.py", line 1533, in raise RuntimeError("Gtk couldn't be initialized") RuntimeError: Gtk couldn't be initialized i'm not sure what the problem is in here any help will be appreciated

tylla commented 9 years ago

@bmccarthy @redstar3894 I was able to install the previous version (0.11-6) on a squeeze (6.0) Debian system by extracting the package, editing the control file and the postinst file to lower the required Python version and repacking the package. And it worked... at least to the point of giving me the error mentioned in the issue title. But I'm afraid this time it won't work as squeeze is really far from systemd.

@davesteele Thank you for the prompt answer. Is your code (the simple cloudprint, not the service part) using anything specific to Python 2.7? Because if not, then the requirements could be lowered to Python 2.6 so those few of us with older Debian systems could use the package without any extra work.

Update: It seems that even the simple cloudprint needs Python 2.7 at least on Debian squeeze it dies with this:

Starting Google Cloud Print: Traceback (most recent call last):
  File "/usr/local/bin/cloudprint", line 9, in <module>
    load_entry_point('cloudprint==0.11', 'console_scripts', 'cloudprint')()
  File "/usr/local/lib/python2.6/dist-packages/cloudprint/cloudprint.py", line 457, in main
    cpp.username = account_file.next().rstrip()
StopIteration
davesteele commented 9 years ago

@akabaka74, if this is on a server without a graphical environment, it looks like it fails differently than I expected. For a workaround, you can edit cpoauth.py to guarantee that one of the 'gi' imports fails with an ImportError ( or add RuntimeError to the exception list, the better choice).

@tylla, I don't support installation on Python 2.6 because I don't test it. I'd accept patches for that.

motorkap commented 9 years ago

Dave, re "Cloudprint-service requires systemd now. If that is too much of a headache, you can run cloudprint bare (e.g. cloudprint -d) till things settle down."

When I installed systemd the cloudprint-service got uninstalled. If I then try to re-install cloudprint-service, the system removes systemd (see below). If I try to install cloudprint it fails needing python >= 2.7, but my python version is 2.7.1

I'd like to help with this but I don't have a lot of linux knowledge, and I just got stuck again.


pi@SqueezePi ~ $ sudo apt-get install cloudprint-service Reading package lists... Done Building dependency tree
Reading state information... Done The following packages were automatically installed and are no longer required: libcryptsetup4 libsystemd-id128-0 libsystemd-journal0 Use 'apt-get autoremove' to remove them. The following extra packages will be installed: init-system-helpers The following packages will be REMOVED: libpam-systemd systemd The following NEW packages will be installed: cloudprint-service init-system-helpers 0 upgraded, 2 newly installed, 2 to remove and 1 not upgraded. Need to get 0 B/23.1 kB of archives. After this operation, 3379 kB disk space will be freed. Do you want to continue [Y/n]? n Abort. pi@SqueezePi ~ $ python --version Python 2.7.3 pi@SqueezePi ~ $ sudo apt-get install cloudprint Reading package lists... Done Building dependency tree
Reading state information... Done Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation:

The following packages have unmet dependencies: cloudprint : Depends: python:any (>= 2.7) but it is not installable E: Unable to correct problems, you have held broken packages.

davesteele commented 9 years ago

@motorkap, I forgot to remove a dependency on the (removed) sysv init system. I'll ship a fix shortly.

tylla commented 9 years ago

@davesteele I'm not sure whether this is a separate issue, so for first I'm writing it here. I managed to install the cloudprint package to a newly installed Debian Jessie and when I try to start it I get two similar error messages:

root@cloudprint:~# cloudprint -a /root/.cloudprintauth -vvv
Unable to init server: Could not connect: Connection refused
Unable to init server: Could not connect: Connection refused
Setting DEBUG-level logging
Skipping Kyocera_FS-6525MFP
Skipping kyocera-tanari-gimi
Skipping Kyocera_TASKalfa_2551ci
^CTraceback (most recent call last):
......

The starting traceback is for the CTRL-C I hit after a few seconds.

Am I missing something? Any thoughts, suggestions?

akabakass commented 9 years ago

ok, thanks to yo, i finally manage to run cloudprint, by replacing except ImportError with except RuntimeError and by getting credential on a desktop computer.(be carfull, when starting it print all the jobs launched since the faillure). i've try to make the cloudprint service working, actually, when i try to install cloudprint-service, i still get get

cloudprint-service : Depends: init-system-helpers (>= 1.18~) but it is not installable, i manage to install with tylia repacking trick, but as i am on ubuntu precise, i don't have systemd so it didn't work.

also something weird here is that i've installed init-system-helper 1.7 (from nginx)and still get the sme depend error with apt-get.

i'm not sure i'll go any further on this, if so, i'll inform you. anyway thxs a lot for the help cheers

tylla commented 9 years ago

@akabaka74 watch out, your installed init-system-helper 1.7 is older than the required 1.18 so that's why you still get apt-get errors. (7 < 18 ;-) The repack trick worked until cloudprint-service didn't depended on systemd, now it's useless.

akabakass commented 9 years ago

Of course, noob error,thks

davesteele commented 9 years ago

I have some dependency errors that are causing install problems - I'll fix those shortly.

The latest cloudprint-service won't be useful to you unless you have systemd (which is in Debian stable). If you are adventurous, you can get and install just the old init script to /etc/init.d/cloudprintd.

davesteele commented 9 years ago

@tylla, for python 2.6, see armooo/cloudprint#97

hubertbanas commented 9 years ago

Are there any plans to officially support init.d sometime in the future or it is systemd only from now on? I believe there are a lot of older still supported installs that would beneficial from init.d.

davesteele commented 9 years ago

I only did the system conversion because my init.d environment appeared to be broken.

I have no need to go back to sysv init, but would be happy to accept patches for dual environment support.

akabakass commented 9 years ago

i've used this to make the normal cloudprint work with init.d inside /etc/init.d/cloudprint, paste:

!/bin/bash

/etc/rc.d/cloudprint

Description: Starts the Google Cloud Print script on startup

----------------

#

BEGIN INIT INFO

Provides: Cloud-Print

Required-Start: $cups $network $local_fs $syslog

Required-Stop: $local_fs $syslog

Default-Start: 2 3 4 5

Default-Stop: 0 1 6

Description: Start Google Cloud Print

END INIT INFO

USER="root" PIDFILE="/var/run/cloudprint/pid"

case $1 in start) echo -n "Starting Google Cloud Print: " sudo -u $USER cloudprint -d -p $PIDFILE ;; stop) echo -n "Stopping Google Cloud Print: " killall cloudprint ;; restart) echo -n "Restarting Google Cloud Print: " killall cloudprint sudo -u $USER cloudprint -d -p $PIDFILE ;; *) echo "Usage: cloudprint {start|stop|restart}" ;; esac

and then run update-rc.d cloudprint defaults to add it to yours rcX.d (start with the server) with so you can run the /etv/init.d/cloudprint start||stop||restart or service cloudprint start||stop||restart

tylla commented 9 years ago

@davesteele Thank you for pointing out the python 2.6 solution. I will give it a try soon.

Do you have some suggestion about my issue with the "Unable to init server: Could not connect: Connection refused" error?

mfraser commented 9 years ago

Tried running cloudprint -c from my desktop, but it is failing with: Graphical environment needed for OAuth2 login Tried cloudprint-auth username, but that returns Traceback (most recent call last): File "/usr/bin/cloudprint-auth", line 9, in load_entry_point('cloudprint==0.11', 'console_scripts', 'cloudprint-auth')() File "/usr/share/cloudprint/cloudprint/cpoauth.py", line 166, in main access, refresh = oauth.generate_tokens(login) File "/usr/share/cloudprint/cloudprint/cpoauth.py", line 137, in generate_tokens code = self.get_code(login) File "/usr/share/cloudprint/cloudprint/cpoauth.py", line 59, in get_code bro = WebKit.WebView() NameError: global name 'WebKit' is not defined

davesteele commented 9 years ago

@tylla, I suspect you don't have the authentication set up.

@mfraser, the login code is looking for a GNOME environment, and the python-gi package.

mfraser commented 9 years ago

On 3 Jun 2015 12:39, "davesteele" notifications@github.com wrote:

@tylla, I suspect you don't have the authentication set up.

@mfraser, the login code is looking for a GNOME environment, and the python-gi package.

That would explain it, I'm using a KDE desktop.

— Reply to this email directly or view it on GitHub.

mfraser commented 9 years ago

On 3 Jun 2015 12:39, "davesteele" notifications@github.com wrote:

@tylla, I suspect you don't have the authentication set up.

@mfraser, the login code is looking for a GNOME environment, and the python-gi package.

python-gi package is installed.

tylla commented 9 years ago

@davesteele Nope, authentication is OK, I suspected that in some ways ssh's X11-forwarding was the cause. At least when I tried with the -Y flag to enable trusted forwarding, it changed the error message to some dbus activation message. Ahh, never mind. I found out the real cause of my problem was that when I set up my new test machine, (in an bitter attempt to invisibly replace the printers behind the back of Google) I only copied the printer definition for CUPS but I forgot the .ppd files, so your code just skipped those printers as it should. Just a suggestion: the "Skipping " + printer_name (cloudprint.py:314) string maybe should be changed to something like: to "Parsing the PPD file of '" + printer_name + "' failed, skipping." Now that I studied your code, now it's clear what means "Skipped", but for first I couldn't really find out the cause. :)

So worksforme!

dmonty2 commented 9 years ago

@davesteele - would you be able to drop the GTK Gnome/GUI requirement? One of the reasons why we went to cloudprint/service is so that we could drop the requirement for installing a running a full blown desktop environment with Google Chrome. Plus we like the INCLUDE/EXCLUDE feature.

davesteele commented 9 years ago

@dmonty2 - Upstream removes the desktop requirement by printing a URL that must be visited elsewhere. My solution also has a remote auth script. Bottom line, you need a graphical environment somewhere for OAuth2

INCLUDE/EXCLUDE will be back.

davesteele commented 8 years ago

See #36 for resolution.