bernigaud / googlecl

Automatically exported from code.google.com/p/googlecl
0 stars 0 forks source link

Usage with Google Apps Calendars, Contacts, etc. #49

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When I use a Google Apps email as a username after doing my first "google 
calendar add", I am redirected to a Gmail.com login rather than my Google Apps 
for my domain login, which entirely prevents me from posting to my Google Apps 
accounts.  Is there a way to do this now or will it be possible to do this in 
the future?

Original issue reported on code.google.com by webav...@gmail.com on 18 Jun 2010 at 10:23

GoogleCodeExporter commented 9 years ago
This issue affect my too. There are several situations I have noticed where 
Google for domains doesn't integrate nicely with the rest of the suite of 
tools. ex. Try changing your google for domains password. The picasa (and 
others) password doesn't follow.

Original comment by otheracc...@zivan.com on 18 Jun 2010 at 10:52

GoogleCodeExporter commented 9 years ago
Can you both list the exact command that you used and the version of gdata that 
you are using?

Original comment by tom.h.mi...@gmail.com on 19 Jun 2010 at 8:36

GoogleCodeExporter commented 9 years ago
Here is a related issue with Google for Domains. When I log in to my Google for 
Domains account (zach@42lines.net) and try to create a new document (or edit an 
existing one), I get an error. If I go to the web interface for Documents for 
my domain I see the document has been newly created (empty), but I can't 
actually edit it using the CL tool. 

zach42@coach-z:~$ google docs edit --editor vi
Did not find config / preferences file at /home/zach42/.googlecl/config
... making new one.
Please specify title: Foo
Please specify user: zach@42lines.net
Please log in and/or grant access via your browser at 
https://www.google.com/accounts/OAuthAuthorizeToken?oauth_token=4%2FRVUigHZxGsza
rwveXm4pIDki5qwW then hit enter.
No matching documents found! Creating it.
Traceback (most recent call last):
  File "/usr/bin/google", line 463, in <module>
    main()
  File "/usr/bin/google", line 457, in main
    run_once(options, args)
  File "/usr/bin/google", line 356, in run_once
    task.run(client, options, args)
  File "/usr/lib/pymodules/python2.5/googlecl/docs/service.py", line 439, in _run_edit
    client.edit_doc(doc_entry, editor, format_ext)
  File "/usr/lib/pymodules/python2.5/googlecl/docs/service.py", line 104, in edit_doc
    self.Export(doc_entry.content.src, path)
  File "/usr/lib/pymodules/python2.5/gdata/docs/service.py", line 360, in Export
    self.Download(entry_or_id_or_url, file_path, ext, gid, extra_params)
  File "/usr/lib/pymodules/python2.5/gdata/docs/service.py", line 339, in Download
    self._DownloadFile(url, file_path)
  File "/usr/lib/pymodules/python2.5/gdata/docs/service.py", line 177, in _DownloadFile
    'body': response_body}
gdata.service.RequestError: {'status': 302, 'body': 
'<HTML>\n<HEAD>\n<TITLE>Moved Temporarily</TITLE>\n</HEAD>\n<BODY 
BGCOLOR="#FFFFFF" TEXT="#000000">\n<H1>Moved Temporarily</H1>\nThe document has 
moved <A 
HREF="https://docs.google.com/feeds/download/documents/Export?exportFormat=txt&d
ocId=0AUObs7dybjLVZGdxanNkaHdfNGR2d3htaGM1">here</A>.\n</BODY>\n</HTML>\n', 
'reason': 'Moved Temporarily'}

zach42@coach-z:~$ dpkg --list | grep gdata
ii  libgdata-common                       0.6.4-2                             
Library for accessing GData webservices - co
ii  libgdata-google1.2-1                  2.28.3.1-1                          
Client library for accessing Google POA thro
ii  libgdata1.2-1                         2.28.3.1-1                          
Client library for accessing Google POA thro
ii  libgdata7                             0.6.4-2                             
Library for accessing GData webservices - sh
ii  python-gdata                          2.0.8-1.1                           
Google Data Python client library

Original comment by zacha...@gmail.com on 21 Jun 2010 at 2:45

GoogleCodeExporter commented 9 years ago
As far as I understood the authentication API OAuth, which is used by googlecl 
is available only for Google Apps Premier and Education Edition. If this is the 
case for your Google Apps accounts then it can be considered as a bug in 
googlecl.

If you're using Google Apps Standard Edition the only way to access your 
account is to use ClientLogin API based on providing username and password, 
which is not implemented in googlecl at the moment. I can try to implement this 
if needed. 

Please let me know which type of Google Apps account do you have. Unfortunately 
I have only Standard Edition account, so I can't help with fixing googlecl for 
working with Premier and Education edition accounts.

Regards,
Ed Bartosh

Original comment by bart...@gmail.com on 27 Jun 2010 at 10:00

GoogleCodeExporter commented 9 years ago
I have Google Apps Standard Edition and I would love to use googlecl.

Original comment by laurensv...@gmail.com on 27 Jun 2010 at 10:38

GoogleCodeExporter commented 9 years ago
Try this patch then. It works for me at least with Google Apps calendar and 
docs. I'm pretty sure that there is a better way to distinguish between Google 
Apps account and usual Google account, but I do it by checking email address. 
If it doesn't end with 'gmail.com' I consider it as a Google Apps account and 
use username/password authentication. 

Here are couple of examples:
1. Get today entries from Google Apps calendar
$ google calendar today --user ed@bartosh.org --password xxxxx
[ed@bartosh.org]
Test Google Apps calendar,Jun 27 14:00 - Jun 27 15:00

2. The same without specifying password in the commandline (more secure way):
$ google calendar today --user ed@bartosh.org
Enter password: # typed password here
[ed@bartosh.org]
Test Google Apps calendar,Jun 27 14:00 - Jun 27 15:00

3. The same for Google calendar (password is not required):
$ google calendar today --user bartosh@gmail.com
[bartosh@gmail.com]
Test Google calendar,Jun 27 18:30 - Jun 27 19:30

Original comment by bart...@gmail.com on 27 Jun 2010 at 3:27

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by bart...@gmail.com on 27 Jun 2010 at 3:50

Attachments:

GoogleCodeExporter commented 9 years ago
I applied the patch to the googlecl trunk and installed it. Now I can list the 
docs in my google apps account. But I still can't edit them. I used the 
following command:

google docs edit --user me@mydomain.com --title "Test GoogleCL" --editor vim

I entered the password and then after a while it failed with the following 
error:

Traceback (most recent call last):
  File "/usr/local/bin/google", line 469, in <module>
    main()
  File "/usr/local/bin/google", line 463, in main
    run_once(options, args)
  File "/usr/local/bin/google", line 360, in run_once
    task.run(client, options, args)
  File "/usr/local/lib/python2.6/dist-packages/googlecl/docs/service.py", line 491, in _run_edit
    client.edit_doc(doc_entry, editor, format_ext)
  File "/usr/local/lib/python2.6/dist-packages/googlecl/docs/service.py", line 93, in edit_doc
    self.Export(doc_entry.content.src, path)
  File "/usr/local/lib/python2.6/dist-packages/gdata/docs/service.py", line 361, in Export
    self.Download(entry_or_id_or_url, file_path, ext, gid, extra_params)
  File "/usr/local/lib/python2.6/dist-packages/gdata/docs/service.py", line 340, in Download
    self._DownloadFile(url, file_path)
  File "/usr/local/lib/python2.6/dist-packages/gdata/docs/service.py", line 178, in _DownloadFile
    'body': response_body}
gdata.service.RequestError: {'status': 302, 'body': 
'<HTML>\n<HEAD>\n<TITLE>Moved Temporarily</TITLE>\n</HEAD>\n<BODY 
BGCOLOR="#FFFFFF" TEXT="#000000">\n<H1>Moved Temporarily</H1>\nThe document has 
moved <A 
HREF="https://docs.google.com/feeds/download/documents/Export?exportFormat=txt&d
ocId=0AZPqQnIzeyKWZGcycXJrczVfMTljeDhoYm5oZA">here</A>.\n</BODY>\n</HTML>\n', 
'reason': 'Moved Temporarily'}

However I noticed that a new empty document with the specified title has been 
created in the account. I just can't edit it. Any ideas?

Original comment by hiranya...@gmail.com on 28 Jun 2010 at 6:52

GoogleCodeExporter commented 9 years ago
Can you try other operations with the documents (get, upload, delete), please? 
I'll try to fix this today evening(EET time), but I need as many details as 
possible.
Thanks

Original comment by bart...@gmail.com on 28 Jun 2010 at 7:48

GoogleCodeExporter commented 9 years ago
Thanks for looking into this. I just tried a few more operations. The get 
operation failed:

Downloading Test GoogleCL to 
/home/hiranya/Projects/Test/googlecl-read-only/Test GoogleCL.txt
{'status': 302, 'body': '<HTML>\n<HEAD>\n<TITLE>Moved 
Temporarily</TITLE>\n</HEAD>\n<BODY BGCOLOR="#FFFFFF" 
TEXT="#000000">\n<H1>Moved Temporarily</H1>\nThe document has moved <A 
HREF="https://docs.google.com/feeds/download/documents/Export?exportFormat=txt&d
ocId=0AZPqQnIzeyKWZGcycXJrczVfMTljeDhoYm5oZA">here</A>.\n</BODY>\n</HTML>\n', 
'reason': 'Moved Temporarily'}
Download of Test GoogleCL failed

The delete was successful. I will try and see how the upload goes.

Original comment by hiranya...@gmail.com on 28 Jun 2010 at 9:10

GoogleCodeExporter commented 9 years ago
Thanks, bartosh (and issue-filers). I don't have access to any kind of Apps 
account, so this is very helpful.

I'm reluctant to use ClientLogin because it's scheduled for deprecation, but if 
it's the best solution for Apps users, I'll include it.

In the meantime, could some intrepid Apps users also try this patch? (applied 
to r301) Instead of using ClientLogin, it sets the hd query parameter 
(http://code.google.com/apis/accounts/docs/OAuth_ref.html#hd), which should put 
you at the correct login screen. Be sure to erase any access tokens you have 
for your Apps accounts in ~/.googlecl (you shouldn't have any there to begin 
with if you've been having issues).

On support: I've only found documentation 
(http://www.google.com/support/a/bin/answer.py?hl=en&answer=61017) saying that 
2-legged OAuth is supported for premiere and education editions, but standard 
edition users should be ok with the "default" 3-legged procedure.

On 302 errors: See issue 167.

Original comment by tom.h.mi...@gmail.com on 28 Jun 2010 at 2:07

GoogleCodeExporter commented 9 years ago
Patch referenced in comment 10 actually attached in this one...

Original comment by tom.h.mi...@gmail.com on 28 Jun 2010 at 2:08

Attachments:

GoogleCodeExporter commented 9 years ago
Issue 153 has been merged into this issue.

Original comment by tom.h.mi...@gmail.com on 28 Jun 2010 at 2:31

GoogleCodeExporter commented 9 years ago
Issue 177 has been merged into this issue.

Original comment by tom.h.mi...@gmail.com on 28 Jun 2010 at 2:34

GoogleCodeExporter commented 9 years ago
Your patch is working fine. I was able to get list of documents and edit 
document from my Google Apps account. However, for some reason I was not able 
to authenticate with my @gmail.com account. I got this error in my browser: 
"Sorry, you've reached a login page for a domain that isn't using Google Apps. 
Please check the web address and try again.". I think it's because with hd 
parameter gdata API assumes that it should authenticate user for Google Apps 
domain. Did it work for you?

After this tiny change (ugly one, I know :)) everything started to work just 
fine:
--- src/google  (revision 304)
+++ src/google  (working copy)
@@ -202,6 +202,8 @@

   """
   name, at_sign, domain = username.partition('@')
+  if domain == 'gmail.com':
+    return default_domain
   return domain or default_domain

PS: That's great! We don't need to use UserLogin then. May be I misread 
something about OAuth support for Apps domains, but I remember that I tried to 
use hd parameter and it didn't work for me. Anyway now it works and this ticket 
can be closed.

Original comment by bart...@gmail.com on 28 Jun 2010 at 5:43

GoogleCodeExporter commented 9 years ago
r307 includes the mini-patch bartosh posted, and thus fixes this issue.

Original comment by tom.h.mi...@gmail.com on 28 Jun 2010 at 7:33

GoogleCodeExporter commented 9 years ago

Original comment by tom.h.mi...@gmail.com on 28 Jun 2010 at 7:33

GoogleCodeExporter commented 9 years ago
Folks,

Thanks again for looking into this. But I'm still having issues, editing the 
documents in my Google Apps account. I checked out the latest trunk (r308) and 
installed GoogleCL from it. Now when I try to list or edit the docs my browser 
pops up and it tries to authenticate against my Google Apps account. So that 
part is working fine I guess. But still when I try to edit a doc the following 
error appears:

Traceback (most recent call last):
  File "/usr/local/bin/google", line 488, in <module>
    main()
  File "/usr/local/bin/google", line 482, in main
    run_once(options, args)
  File "/usr/local/bin/google", line 381, in run_once
    task.run(client, options, args)
  File "/usr/local/lib/python2.6/dist-packages/googlecl/docs/service.py", line 492, in _run_edit
    client.edit_doc(doc_entry, editor, format_ext)
  File "/usr/local/lib/python2.6/dist-packages/googlecl/docs/service.py", line 93, in edit_doc
    self.Export(doc_entry.content.src, path)
  File "/usr/lib/pymodules/python2.6/gdata/docs/service.py", line 360, in Export
    self.Download(entry_or_id_or_url, file_path, ext, gid, extra_params)
  File "/usr/lib/pymodules/python2.6/gdata/docs/service.py", line 339, in Download
    self._DownloadFile(url, file_path)
  File "/usr/lib/pymodules/python2.6/gdata/docs/service.py", line 177, in _DownloadFile
    'body': response_body}
gdata.service.RequestError: {'status': 302, 'body': 
'<HTML>\n<HEAD>\n<TITLE>Moved Temporarily</TITLE>\n</HEAD>\n<BODY 
BGCOLOR="#FFFFFF" TEXT="#000000">\n<H1>Moved Temporarily</H1>\nThe document has 
moved <A 
HREF="https://docs.google.com/feeds/download/documents/Export?exportFormat=txt&d
ocId=0AZPqQnIzeyKWZGcycXJrczVfMjBmejdtcDJkZw">here</A>.\n</BODY>\n</HTML>\n', 
'reason': 'Moved Temporarily'}

It's more or less the same error I got earlier. Any help would be mush 
appreciated.

Original comment by hiranya...@gmail.com on 29 Jun 2010 at 4:54

GoogleCodeExporter commented 9 years ago
The get doesn't work either:

Downloading Test GoogleCL to 
/home/hiranya/Projects/Test/googlecl-read-only/Test GoogleCL.txt
{'status': 302, 'body': '<HTML>\n<HEAD>\n<TITLE>Moved 
Temporarily</TITLE>\n</HEAD>\n<BODY BGCOLOR="#FFFFFF" 
TEXT="#000000">\n<H1>Moved Temporarily</H1>\nThe document has moved <A 
HREF="https://docs.google.com/feeds/download/documents/Export?exportFormat=txt&d
ocId=0AZPqQnIzeyKWZGcycXJrczVfMjBmejdtcDJkZw">here</A>.\n</BODY>\n</HTML>\n', 
'reason': 'Moved Temporarily'}
Download of Test GoogleCL failed

Original comment by hiranya...@gmail.com on 29 Jun 2010 at 5:29

GoogleCodeExporter commented 9 years ago
My system environment:

OS: Ubuntu 9.04 64-bit
python-gdata: 2.0.8
python: 2.6

Original comment by hiranya...@gmail.com on 29 Jun 2010 at 9:32

GoogleCodeExporter commented 9 years ago
Hmm. I checked get and edit modes yesterday. It worked for me.
I'll re-check today evening (EEST timezone).

Original comment by bart...@gmail.com on 29 Jun 2010 at 10:29

GoogleCodeExporter commented 9 years ago
302 rears its ugly head. Please take this discussion to Issue 167, since it's 
no longer relevant to the login issues people were having. (and be sure to read 
the request for information in the initial issue).

It is interesting to note that the 302 seems to favor Apps users on Docs. Or 
that's just the most popular user profile, which is also good to know.

Original comment by tom.h.mi...@gmail.com on 29 Jun 2010 at 1:35

GoogleCodeExporter commented 9 years ago
Issue 138 has been merged into this issue.

Original comment by tom.h.mi...@gmail.com on 23 Jul 2010 at 9:29

GoogleCodeExporter commented 9 years ago
Issue 151 has been merged into this issue.

Original comment by tom.h.mi...@gmail.com on 23 Jul 2010 at 11:29