Skip to content

ApiError: Insufficient Permission even when the same API wrote the file to Storage #1017

Closed

Description

@ajpyoung

I'm at a loss here. My node code successfully uploaded files to gcloud Storage but can't seem to make the file public or even change the acl.

The error returned is

{ [ApiError: Insufficient Permission]
errors:
 [ { domain: 'global',
     reason: 'insufficientPermissions',
     message: 'Insufficient Permission' } ],
code: 403,
message: 'Insufficient Permission',
response: undefined }

Here's my code

var gcs = GLOBAL.gcloud.storage();
var bucket = gcs.bucket(GLOBAL.storage_names.products);
var file = bucket.file('images/'+targetValue+'_'+filename);
stdout.pipe(file.createWriteStream())
  .on('error', function(err) {
    var msg = {
      "status":"Error"
      "err":err
    };
    console.log(msg);

  })
  .on('finish', function() {
    // The file upload is complete.
    console.log("Successfully uploaded "+targetValue+'_'+filename);
    file.acl.add({
      entity: 'allUsers',
      role: gcs.acl.READER_ROLE
    }, function(err, aclObject) {

      if(err==null)
      {
        //stream upload file
        file.makePublic();
      }else{
        console.log("ERROR in ACL Adding");
        console.log(err)
      }

    });
    file.makePublic(function(err, apiResponse) {
      if(err==null)
      {
        console.log("File made public");
      }else{
        console.log("make public error");
        console.log(err);
      }
    });
  });

Activity

  1. stephenplusplus commented on Dec 12, 2015

    @stephenplusplus
    Contributor

    It looks like the only way it's working for me is when I provide a keyFilename path to a service account key file. I was able to reproduce the error when trying to update the ACL as an authenticated user.

    @jgeewax is this intentional, or is something off here?

  2. ajpyoung commented on Dec 14, 2015

    @ajpyoung
    Author

    One note though, this error was in the Compute Engine environment and not in the app engine environment and I did not use the keyfilename inside the Compute Engine environment

  3. ajpyoung commented on Dec 14, 2015

    @ajpyoung
    Author

    I did an experiment where I set the bucket allUsers as owner. Used the same program to upload pictures to the bucket and change the permissions through Compute Engine and the same error happened

  4. stephenplusplus commented on Dec 14, 2015

    @stephenplusplus
    Contributor
  5. theacodes commented on Dec 14, 2015

    @theacodes

    @ajpyoung can you share with me your compute engine instance's scopes? run gcloud compute instances describe your-instance-name and the scopes should be listed under the serviceAccounts section.

  6. ajpyoung commented on Dec 15, 2015

    @ajpyoung
    Author

    @stephenplusplus - the link you posted was written by me.
    @jonparrott - sure... I hope this is what your looking for

    serviceAccounts:
    
      scopes:
      - https://www.googleapis.com/auth/cloud-platform
    status: RUNNING
    
  7. stephenplusplus commented on Dec 15, 2015

    @stephenplusplus
    Contributor

    @ajpyoung I know :) It's helpful to link all of the places you post an issue.

  8. theacodes commented on Dec 15, 2015

    @theacodes

    @ajpyoung can you try with a new instance that has both cloud_platform and devstorage.full_control?

  9. ajpyoung commented on Dec 16, 2015

    @ajpyoung
    Author

    @jonparrott - umm, sorry for asking this but how do I do that? I'm on the Google Cloud dashboard, clicked on Compute Engine and clicked on VM Instance and then New Instance.

    Add tags and firewall rules to allow specific network traffic from the Internet

    Allow HTTP traffic
    Allow HTTPS traffic

    Project access
    Allow API access to all Google Cloud services in the same project.

    How do I activate devstorage.full_control?

  10. theacodes commented on Dec 16, 2015

    @theacodes

    sorry for asking

    You don't have to apologize. :)

    I seems you can no longer do this easily in the UI, so here's the command line to do it:

    gcloud compute instances create instance-name --scopes "https://www.googleapis.com/auth/devstorage.full_control","cloud-platform"
    
  11. ajpyoung commented on Dec 18, 2015

    @ajpyoung
    Author

    @jonparrott - sorry for the delayed response, I've been busy writing technical papers for a Patent for the company I work for. Thank you for your help, I'll execute this process ASAP and reply before the week ends. Again my apologies for my tardiness in replying and thank you for your assistance in this.

  12. theacodes commented on Dec 18, 2015

    @theacodes

    No worries. :) I will be on vacation until 2016 so I may not be able to
    review your response quickly.

    On Thu, Dec 17, 2015, 6:36 PM Andrew John P. Young [email protected]
    wrote:

    @jonparrott https://github.com/jonparrott - sorry for the delayed
    response, I've been busy writing technical papers for a Patent for the
    company I work for. Thank you for your help, I'll do execute this process
    ASAP and reply before the week ends. Again my apologies for my tardiness in
    replying and thank you for your assistance in this.

    —
    Reply to this email directly or view it on GitHub
    #1017 (comment)
    .

  13. stephenplusplus commented on Jan 9, 2016

    @stephenplusplus
    Contributor

    @ajpyoung happy new year! 🎉 Just doing a little issue cleaning, are there any updates for how this one is progressing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

api: storageIssues related to the Cloud Storage API.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions