iwonbigbro / gsync

RSync for Google Drive - GSync
Other
238 stars 50 forks source link

Prompted again to authenticate and unable to sync anything [Invalid grant] #61

Open WalshIO opened 10 years ago

WalshIO commented 10 years ago

Issue: Unable to sync, prompted to enter code again right after running --authenticate

OS: Trusty 14.04 for ARM (crouton on arm chromebook) Python 2.7.6 Running gsync from todays git pull My computer is ntpdate synced in case it time skew caused credential failure with google.

After all this I also notice that ~/.gsync/credentials is empty

rm -rf ~/.gsync (trusty)user@localhost:~$ gsync --debug --authenticate DEBUG: /usr/local/lib/python2.7/dist-packages/gsync-0.1.14-py2.7.egg/EGG-INFO/scripts/gsync:51:main(): {'--8-bit-output': 0, '--append': 0, '--authenticate': True, '--backup': 0, '--backup-dir': [], '--bwlimit': [], '--checksum': 0, '--chmod': [], '--compare-dest': [], '--contimeout': [], '--copy-dest': [], '--copy-dirlinks': 0, '--copy-links': 0, '--copy-unsafe-links': 0, '--cvs-exclude': 0, '--debug': True, '--del': 0, '--delay-updates': 0, '--delete': 0, '--delete-after': 0, '--delete-before': 0, '--delete-delay': 0, '--delete-during': 0, '--delete-excluded': 0, '--dirs': 0, '--dry-run': 0, '--exclude': [], '--exclude-from': [], '--executability': 0, '--existing': 0, '--fake-super': 0, '--files-from': [], '--filter': [], '--force': 0, '--from0': 0, '--fuzzy': 0, '--group': 0, '--hard-links': 0, '--help': 0, '--human-readable': 0, '--ignore-errors': 0, '--ignore-existing': 0, '--ignore-times': 0, '--include': [], '--include-from': [], '--itemize-changes': 0, '--keep-dirlinks': 0, '--links': 0, '--list-only': 0, '--log-file': [], '--log-file-format': [], '--max-delete': [], '--max-size': [], '--min-size': [], '--modify-window': [], '--no-implied-dirs': 0, '--omit-dir-times': 0, '--one-file-system': 0, '--out-format': [], '--owner': 0, '--partial': 0, '--partial-dir': [], '--perms': 0, '--progress': 0, '--protect-args': 0, '--proxy': 0, '--prune-empty-dirs': 0, '--quiet': 0, '--recursive': 0, '--relative': 0, '--remove-source-files': 0, '--safe-links': 0, '--size-only': 0, '--sparse': 0, '--stats': 0, '--suffix': [], '--super': 0, '--temp-dir': [], '--timeout': [], '--times': 0, '--update': 0, '--verbose': 0, '--version': 0, '-F': 0, '-P': 0} DEBUG: drive/:272:init(): Initialising drive DEBUG: drive/:280:init(): Initialisation complete DEBUG: drive/:419:_get_credential_storage(): Loading storage DEBUG: drive/:392:_get_config_dir(): Config dir = /home/user/.gsync DEBUG: drive/:409:_get_config_file(): Environment: GSYNC_CREDENTIALS=/home/user/.gsync/credentials DEBUG: drive/:392:_get_config_dir(): Config dir = /home/user/.gsync DEBUG: drive/:409:_get_config_file(): Environment: GSYNC_CLIENT_JSON=/home/user/.gsync/client.json Authorization is required to access your Google Drive. Navigate to the following URL: https://accounts.google.com/o/oauth2/auth?scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&response_type=code&client_id=542942405111.apps.googleusercontent.com&access_type=offline Type in the received code: 4/[TRIMMED FOR PRIVACY] DEBUG: drive/:340:service(): Authenticating DEBUG: drive/:392:_get_config_dir(): Config dir = /home/user/.gsync DEBUG: drive/:349:service(): Loading Google Drive service from config DEBUG: drive/:353:service(): Downloading API service DEBUG: drive/:370:service(): Building Google Drive service from document (trusty)user@localhost:~$ gsync drive://CrOS ~/Foo Authorization is required to access your Google Drive. Navigate to the following URL: https://accounts.google.com/o/oauth2/auth?scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&response_type=code&client_id=542942405111.apps.googleusercontent.com&access_type=offline Type in the received code: 4/[TRIMMED FOR PRIVACY] DEBUG: FlowExchangeError(u'invalid_grant',): invalid_grant DEBUG: FlowExchangeError(u'invalid_grant',): File "/usr/local/lib/python2.7/dist-packages/gsync-0.1.14-py2.7.egg/EGG-INFO/scripts/gsync", line 82, in main Crawler(src, dest).run() File "/usr/local/lib/python2.7/dist-packages/gsync-0.1.14-py2.7.egg/libgsync/crawler.py", line 53, in init info = self._drive.stat(self._src) File "/usr/local/lib/python2.7/dist-packages/gsync-0.1.14-py2.7.egg/libgsync/drive/init.py", line 659, in stat ents = self._query(parent_id=parent_id) File "/usr/local/lib/python2.7/dist-packages/gsync-0.1.14-py2.7.egg/libgsync/drive/init.py", line 925, in _query with self.service() as service: File "/usr/lib/python2.7/contextlib.py", line 17, in enter return self.gen.next() File "/usr/local/lib/python2.7/dist-packages/gsync-0.1.14-py2.7.egg/libgsync/drive/init.py", line 338, in service credentials = self._obtain_credentials() File "/usr/local/lib/python2.7/dist-packages/gsync-0.1.14-py2.7.egg/libgsync/drive/init.py", line 482, in _obtain_credentials credentials = flow.step2_exchange(code) File "/usr/local/lib/python2.7/dist-packages/oauth2client/util.py", line 132, in positional_wrapper return wrapped(_args, *_kwargs) File "/usr/local/lib/python2.7/dist-packages/oauth2client/client.py", line 1310, in step2_exchange raise FlowExchangeError(error_msg)

gsync: invalid_grant gsync error: FlowExchangeError at drive(482) client=0.1.14user@localhost:~$

jbryant705 commented 10 years ago

Same here. I'm asked to authenticate over and over.

xsbr commented 10 years ago

Drive class has a method del() that saves the credentials on "~/.gsync/credentials" file. For some reason this method was ignored after first authentication.

I made some changes to make sure that credentials will be saved after authentication: https://gist.github.com/xsbr/cd085cd43b30ccf557b7

andreguilhon commented 10 years ago

I'm sorry for my stupidity, but how would I use your commit? I'm facing the same problem, but I can't tell how to get your commit and use it to correct the problem! Could anyone help me?

sudsy commented 9 years ago

@xsbr Have you thought about a pull request for your commits to merge them back into the core project? It seems like a few people have been working on the same bugs because they haven't merged them.