mschilli / net-google-drive-simple

Net::Google::Drive::Simple CPAN Module
Other
11 stars 22 forks source link

response 400 when using google-upsync #1

Closed adam-stokes closed 11 years ago

adam-stokes commented 11 years ago

I was attempting to test this library out with your upsync code and Im getting the following error:

2013/02/21 14:12:25 google-upsync:50> Found 103 local files 2013/02/21 14:12:25 google-upsync:54> Listing Backup on Google Drive Failed with 400: Bad Request at /home/zef/perl5/lib/perl5/Net/Google/Drive/Simple.pm line 459. 2013/02/21 14:12:26 Simple.pm:461> Retrying in 10 seconds

Ive gone through the process of successfully authorizing my application with google and saw that the configuration file was saved with the tokens. However, One odd issue is that the access token is just a tilde rather than a normal looking oauth token is this intended?

update:

More from the log [Thu Feb 21 14:08:36 2013] [debug] GET /callback (Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.69 Safari/537.17). [Thu Feb 21 14:08:36 2013] [debug] Routing to a callback. 400 Bad Request at /home/zef/perl5/bin/google-drive-init line 115. Use of uninitialized value $expires_in in addition (+) at /home/zef/perl5/bin/google-drive-init line 73. [Thu Feb 21 14:08:37 2013] [debug] Rendering cached template layouts/default.html.ep from DATA section. [Thu Feb 21 14:08:37 2013] [debug] 200 OK (0.642733s, 1.556/s).

Looks like the request still never went through even though google-drive-init accepted the callback

mschilli commented 11 years ago

Hi Adam,

make sure that you register your application as "installed application" (not a "web application") on the API panel. Let me know if that fixes it.

adam-stokes commented 11 years ago

I created a new client id and secret and making sure "installed application" and set it to "other" and attempted to re-run the sync script since updating .google-drive.yml. This time an access_token and code parameters in the configuration file were updated, however, I still receive the 400 error.

~ » google-upsync Ubuntu\ One /Backup
2013/02/25 23:19:27 google-upsync:50> Found 103 local files 2013/02/25 23:19:27 google-upsync:54> Listing /Backup on Google Drive Failed with 400: Bad Request at /home/zef/perl5/lib/perl5/Net/Google/Drive/Simple.pm line 459. 2013/02/25 23:19:27 Simple.pm:461> Retrying in 10 seconds

If you like I can email you the token information if you want to try it yourself

Thanks Adam

mschilli commented 11 years ago

Just to make sure your .google-drive.yml file has the correct content, does it look like this?

access_token: ya29.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX client_id: 1234567890123.apps.googleusercontent.com client_secret: 97XXXXXXXXXXXXXXXXXXXXXX code: 4/27XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX expires: 1361878236 refresh_token: 1/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

adam-stokes commented 11 years ago

Everything but refresh_token resembles your output. The refresh_token just shows '~':

refresh_token: ~

mschilli commented 11 years ago

Looks like that's the problem, for some reason you're not getting a refresh token from Google.

Are you using the latest (Net-Google-Drive-Simple-0.04) from CPAN? Also please double-check that you've updated the google-drive-init script accordingly. Here's the steps from the manpage one more time to make sure we haven't overlooked anything:

Click on "Enable the Drive API and SDK", and find "Create an API project in the Google APIs Console". On the API console, create a new project, click "Services", and enable "Drive API" (leave "drive SDK" off). Then, under "API Access" in the navigation bar, create a client ID, and make sure to register a an "installed application" (not a "web application"). "Redirect URIs" should contain "http://localhost". This will get you a "Client ID" and a "Client Secret".

Then, replace the following lines in eg/google-drive-init with the values received:

  # You need to obtain a client_id and a client_secret from
  # https://developers.google.com/drive to use this.
my $client_id     = "XXX";
my $client_secret = "YYY";

Ok .... if all of that is golden, proceed here:

Delete the ~/.google-drive.yml file and run the eg/google-drive-init file again and do the browser dance.

Let me know how it works out, I hope we can get to the bottom of this! -- Mike

adam-stokes commented 11 years ago

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1

On 02/26/2013 10:18 PM, Mike Schilli wrote:

Looks like that's the problem, for some reason you're not getting a refresh token from Google.

Are you using the latest (Net-Google-Drive-Simple-0.04) from CPAN? Also please double-check that you've updated the google-drive-init script accordingly. Here's the steps from the manpage one more time to make sure we haven't overlooked anything:

Click on "Enable the Drive API and SDK", and find "Create an API project in the Google APIs Console". On the API console, create a new project, click "Services", and enable "Drive API" (leave "drive SDK" off). Then, under "API Access" in the navigation bar, create a client ID, and make sure to register a an "installed application" (not a "web application"). "Redirect URIs" should contain "http://localhost". This will get you a "Client ID" and a "Client Secret".

Then, replace the following lines in eg/google-drive-init with the values received:

| # You need to obtain a client_id and a client_secret from # https://developers.google.com/drive to use this. my $client_id = "XXX"; my $client_secret = "YYY"; |

Ok .... if all of that is golden, proceed here:

Delete the ~/.google-drive.yml file and run the eg/google-drive-init file again and do the browser dance.

Let me know how it works out, I hope we can get to the bottom of this! -- Mike

— Reply to this email directly or view it on GitHub https://github.com/mschilli/net-google-drive-simple/issues/1#issuecomment-14154104.

Here is the output from cpanm $ cpanm Net::Google::Drive::Simple Net::Google::Drive::Simple is up to date. (0.04)

$ rm ~/.google-drive.yml

I double checked the google-init file to make sure the client id's were correct. And here is the latest output which is different than the previous so we're making progress

$ google-upsync Ubuntu\ One /Backup 2013/02/26 22:23:42 google-upsync:50> Found 103 local files 2013/02/26 22:23:42 google-upsync:54> Listing /Backup on Google Drive 2013/02/26 22:23:42 Simple.pm:133> API error: Forbidden 2013/02/26 22:23:42 Simple.pm:65> api_test failed after token refresh api_test failed after token refresh at /home/zef/perl5/lib/perl5/Net/Google/Drive/Simple.pm line 65

I verified that the refresh_token is populated

access_token: ya29XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX client_id: 122XXXXXXXXXXXXXXX client_secret: FISXXXXXXXXXXXXXXXXXXXXXXXXXXX code: 4/bXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX expires: 1361938995 refresh_token: 1/OcXXXXXXXXXXXXXXXXXXXXXXXX

Also re-checked to make sure Backup was a folder in my Drive listing.

Thanks!


Adam Stokes adam.stokes@ubuntu.com "Don't salt your green beans before you try them, some may think you make rash decisions." -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Thunderbird-Esr - http://www.enigmail.net/

iQEcBAEBAgAGBQJRLX0TAAoJEBDHSpCZCC2fi2wH/2LE5zypHEvjku2Cdj2Ja9Jd /tnHXWGWIIBoiFWrlAorjEAWsKX4LdSSnp+o1d2TzclkfjkGB7y1NxQMZGqzJ66L Vcp7JPffNzyQYjpqx7/NKyAuFIDLV4QvmTafhFPFQs6exLRcHyG4VOFoNIFIPCJe ARdmHG4KhTp86ISWfQ79omIVVDW+LxIxXVKuVQdM8Dx6bqZBzctg5L8b1mBnbaNq MMxmK0wunAGHlxDB8sgKIQ2bd2IX76dpp5uiXWS5q5fMAKfhp2qSH673sO8ewkCo OnxhNRLVJzff/L/uA1N64RbTurC2Z8ZEdpeTlr4bY4NUOE+2Qh5iPgtp3a78qfI= =JlTF -----END PGP SIGNATURE-----

mschilli commented 11 years ago

Something is still off with your client_id/secret, can you make sure (again) these are correctly reflected in your script?

adam-stokes commented 11 years ago

maybe when i have more time to mess with this ill have another go at it.. thanks!