davidstrauss / google-drive-recursive-ownership

Tool to recursively give away file and document ownership to another user.
MIT License
268 stars 68 forks source link

Getting "Insufficient permissions for this file" - what is correct way to create client_secrets.json? #31

Open jamesbraza opened 4 years ago

jamesbraza commented 4 years ago

I am trying to use this tool, and so far I think it's pretty nifty. I am struggling with what I believe to be a client_secrets.json problem. When running transfer.py, it tries to update ownership permissions of a .jpg file, and fails with the below message:

An error occurred updating ownership permissions: <HttpError 403 when requesting https://www.googleapis.com/drive/v2/files/10-some_text/permissions/some_numbers?transferOwnership=true&alt=json returned "Insufficient permissions for this file">

Based on this Stack Overflow question, it seems I may have my client_secrets.json permissioning all wrong.

I see from within transfer.py it wants to use Drive API v2, and the OAuth2 scope https://www.googleapis.com/auth/drive.

Here is how I generated my client_secrets.json:

  1. Went to https://console.developers.google.com/
  2. Made a project
    • Project name: "xyz" (not the real name)
    • Project ID: went with autogenerated ID
    • Location: No organization
  3. Went to https://console.developers.google.com/apis/library
  4. Enabled Google Drive API
  5. Went to https://console.developers.google.com/apis/credentials/consent
  6. Made an OAuth consent screen
    • Application name: "abc" (not the real name)
    • Support email: my email
    • Left everything else as default
  7. Went to https://console.developers.google.com/apis/credentials/wizard
    • Which API? Google Drive API
    • Where? Other UI
    • What data? User data
  8. It took me to a "Create an OAuth 2.0 client ID" page
    • Name: test-client-id (not the real name)
  9. I hit the Download button --> downloaded client_id.json
    {
    "installed": {
        "client_id": "some_number-some_text.apps.googleusercontent.com",
        "project_id": "xyz",
        "auth_uri": "https://accounts.google.com/o/oauth2/auth",
        "token_uri": "https://oauth2.googleapis.com/token",
        "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
        "client_secret": "some_secret",
        "redirect_uris": ["urn:ietf:wg:oauth:2.0:oob", "http://localhost"]
    }
    }
  10. I copied that file contents over the previous client_secrets.json
  11. And I ran the transfer.py script and got the above warning

What am I doing wrong in generating the client_secrets.json? Can anyone advise?

davidstrauss commented 4 years ago

Hi. I'm not sure what you're doing wrong. Your steps look correct to me. I don't have time to figure this out myself, but I'd be happy to merge a PR with with better documentation on generating the client_secrets.json file if you do.

tilusnet commented 4 years ago

I just want to confirm that I am in the exact same situation today as the OP. I have done very similar (if not identical) steps in getting the client_secrets.json file.

James, did you get any further with investigating this?