Recovering access after initially provisioning wrong scopes for an instance










3














I recently created a VM, but mistakenly gave the default service account Storage: Read Only permissions instead of the intended Read Write under "Identity & API access", so GCS write operations from the VM are now failing.



enter image description hereenter image description here



I realized my mistake, so following the advice in this answer, I stopped the VM, changed the scope to Read Write and started the VM. However, when I SSH in, I'm still getting 403 errors when trying to create buckets.



$ gsutil mb gs://some-random-bucket
Creating gs://some-random-bucket/...
AccessDeniedException: 403 Insufficient OAuth2 scope to perform this operation.
Acceptable scopes: https://www.googleapis.com/auth/cloud-platform


How can I fix this? I'm using the default service account, and don't have the IAM permissions to be able to create new ones.



$ gcloud auth list
Credentialed Accounts
ACTIVE ACCOUNT
* (projectnum)-compute@developer.gserviceaccount.com









share|improve this question























  • Does your personal account have permission to create a bucket? Just wanted to propose a different solution - create the bucket yourself and then grant the service account write permission to the bucket with gsutil acl ch -u (projectnum)-compute@developer.gserviceaccount.com:W gs://example-bucket OR from GCP consul by selecting the bucket and modifying it permissions.
    – Daniel t.
    Nov 10 at 14:04










  • @jpatokal, is any of the answered worked? Please consider to accept the one that fixed the issue or add a comment to update your issue
    – Alioua
    Nov 26 at 19:25















3














I recently created a VM, but mistakenly gave the default service account Storage: Read Only permissions instead of the intended Read Write under "Identity & API access", so GCS write operations from the VM are now failing.



enter image description hereenter image description here



I realized my mistake, so following the advice in this answer, I stopped the VM, changed the scope to Read Write and started the VM. However, when I SSH in, I'm still getting 403 errors when trying to create buckets.



$ gsutil mb gs://some-random-bucket
Creating gs://some-random-bucket/...
AccessDeniedException: 403 Insufficient OAuth2 scope to perform this operation.
Acceptable scopes: https://www.googleapis.com/auth/cloud-platform


How can I fix this? I'm using the default service account, and don't have the IAM permissions to be able to create new ones.



$ gcloud auth list
Credentialed Accounts
ACTIVE ACCOUNT
* (projectnum)-compute@developer.gserviceaccount.com









share|improve this question























  • Does your personal account have permission to create a bucket? Just wanted to propose a different solution - create the bucket yourself and then grant the service account write permission to the bucket with gsutil acl ch -u (projectnum)-compute@developer.gserviceaccount.com:W gs://example-bucket OR from GCP consul by selecting the bucket and modifying it permissions.
    – Daniel t.
    Nov 10 at 14:04










  • @jpatokal, is any of the answered worked? Please consider to accept the one that fixed the issue or add a comment to update your issue
    – Alioua
    Nov 26 at 19:25













3












3








3







I recently created a VM, but mistakenly gave the default service account Storage: Read Only permissions instead of the intended Read Write under "Identity & API access", so GCS write operations from the VM are now failing.



enter image description hereenter image description here



I realized my mistake, so following the advice in this answer, I stopped the VM, changed the scope to Read Write and started the VM. However, when I SSH in, I'm still getting 403 errors when trying to create buckets.



$ gsutil mb gs://some-random-bucket
Creating gs://some-random-bucket/...
AccessDeniedException: 403 Insufficient OAuth2 scope to perform this operation.
Acceptable scopes: https://www.googleapis.com/auth/cloud-platform


How can I fix this? I'm using the default service account, and don't have the IAM permissions to be able to create new ones.



$ gcloud auth list
Credentialed Accounts
ACTIVE ACCOUNT
* (projectnum)-compute@developer.gserviceaccount.com









share|improve this question















I recently created a VM, but mistakenly gave the default service account Storage: Read Only permissions instead of the intended Read Write under "Identity & API access", so GCS write operations from the VM are now failing.



enter image description hereenter image description here



I realized my mistake, so following the advice in this answer, I stopped the VM, changed the scope to Read Write and started the VM. However, when I SSH in, I'm still getting 403 errors when trying to create buckets.



$ gsutil mb gs://some-random-bucket
Creating gs://some-random-bucket/...
AccessDeniedException: 403 Insufficient OAuth2 scope to perform this operation.
Acceptable scopes: https://www.googleapis.com/auth/cloud-platform


How can I fix this? I'm using the default service account, and don't have the IAM permissions to be able to create new ones.



$ gcloud auth list
Credentialed Accounts
ACTIVE ACCOUNT
* (projectnum)-compute@developer.gserviceaccount.com






google-cloud-storage google-compute-engine permission-denied service-accounts






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 7 at 22:43

























asked Nov 7 at 6:05









jpatokal

16.1k55878




16.1k55878











  • Does your personal account have permission to create a bucket? Just wanted to propose a different solution - create the bucket yourself and then grant the service account write permission to the bucket with gsutil acl ch -u (projectnum)-compute@developer.gserviceaccount.com:W gs://example-bucket OR from GCP consul by selecting the bucket and modifying it permissions.
    – Daniel t.
    Nov 10 at 14:04










  • @jpatokal, is any of the answered worked? Please consider to accept the one that fixed the issue or add a comment to update your issue
    – Alioua
    Nov 26 at 19:25
















  • Does your personal account have permission to create a bucket? Just wanted to propose a different solution - create the bucket yourself and then grant the service account write permission to the bucket with gsutil acl ch -u (projectnum)-compute@developer.gserviceaccount.com:W gs://example-bucket OR from GCP consul by selecting the bucket and modifying it permissions.
    – Daniel t.
    Nov 10 at 14:04










  • @jpatokal, is any of the answered worked? Please consider to accept the one that fixed the issue or add a comment to update your issue
    – Alioua
    Nov 26 at 19:25















Does your personal account have permission to create a bucket? Just wanted to propose a different solution - create the bucket yourself and then grant the service account write permission to the bucket with gsutil acl ch -u (projectnum)-compute@developer.gserviceaccount.com:W gs://example-bucket OR from GCP consul by selecting the bucket and modifying it permissions.
– Daniel t.
Nov 10 at 14:04




Does your personal account have permission to create a bucket? Just wanted to propose a different solution - create the bucket yourself and then grant the service account write permission to the bucket with gsutil acl ch -u (projectnum)-compute@developer.gserviceaccount.com:W gs://example-bucket OR from GCP consul by selecting the bucket and modifying it permissions.
– Daniel t.
Nov 10 at 14:04












@jpatokal, is any of the answered worked? Please consider to accept the one that fixed the issue or add a comment to update your issue
– Alioua
Nov 26 at 19:25




@jpatokal, is any of the answered worked? Please consider to accept the one that fixed the issue or add a comment to update your issue
– Alioua
Nov 26 at 19:25












3 Answers
3






active

oldest

votes


















0














Try creating the Google Cloud Storage bucket with your user account.



Type gcloud auth login and access the link you are provided, once there, copy the code and paste it into the command line.



Then do gsutil mb gs://bucket-name.






share|improve this answer




























    0














    The security model has 2 things at play, API Scopes and IAM permissions. Access is determined by the AND of them. So you need an acceptable scope and enough IAM privileges in order to do whatever action.



    • API Scopes are bound to the credentials. They are represented by a URL like, https://www.googleapis.com/auth/cloud-platform.

    • IAM permissions are bound to the identity. These are setup in the Cloud Console's IAM & admin > IAM section.

    This means you can have 2 VMs with the default service account but both have different levels of access.



    For simplicity you generally want to just set the IAM permissions and use the cloud-platform API auth scope.



    To check if you have this setup go to the VM in cloud console and you'll see something like:




    Cloud API access scopes



    Allow full access to all Cloud APIs




    When you SSH into the VM by default gcloud will be logged in as the service account on the VM. I'd discourage logging in as yourself otherwise you more or less break gcloud's configuration to read the default service account.



    Once you have this setup you should be able to use gsutil properly.






    share|improve this answer




























      0














      I will suggest you to try add the scope "cloud-platform" to the instance by running the gcloud command below




      gcloud alpha compute instances set-scopes INSTANCE_NAME [--zone=ZONE]
      [--scopes=[SCOPE,…] [--service-account=SERVICE_ACCOUNT




      As a scopes put "https://www.googleapis.com/auth/cloud-platform" since it give Full access to all Google Cloud Platform resources.



      Here is gcloud documentation






      share|improve this answer




















        Your Answer






        StackExchange.ifUsing("editor", function ()
        StackExchange.using("externalEditor", function ()
        StackExchange.using("snippets", function ()
        StackExchange.snippets.init();
        );
        );
        , "code-snippets");

        StackExchange.ready(function()
        var channelOptions =
        tags: "".split(" "),
        id: "1"
        ;
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function()
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled)
        StackExchange.using("snippets", function()
        createEditor();
        );

        else
        createEditor();

        );

        function createEditor()
        StackExchange.prepareEditor(
        heartbeatType: 'answer',
        autoActivateHeartbeat: false,
        convertImagesToLinks: true,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: 10,
        bindNavPrevention: true,
        postfix: "",
        imageUploader:
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        ,
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        );



        );













        draft saved

        draft discarded


















        StackExchange.ready(
        function ()
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53184334%2frecovering-access-after-initially-provisioning-wrong-scopes-for-an-instance%23new-answer', 'question_page');

        );

        Post as a guest















        Required, but never shown

























        3 Answers
        3






        active

        oldest

        votes








        3 Answers
        3






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        0














        Try creating the Google Cloud Storage bucket with your user account.



        Type gcloud auth login and access the link you are provided, once there, copy the code and paste it into the command line.



        Then do gsutil mb gs://bucket-name.






        share|improve this answer

























          0














          Try creating the Google Cloud Storage bucket with your user account.



          Type gcloud auth login and access the link you are provided, once there, copy the code and paste it into the command line.



          Then do gsutil mb gs://bucket-name.






          share|improve this answer























            0












            0








            0






            Try creating the Google Cloud Storage bucket with your user account.



            Type gcloud auth login and access the link you are provided, once there, copy the code and paste it into the command line.



            Then do gsutil mb gs://bucket-name.






            share|improve this answer












            Try creating the Google Cloud Storage bucket with your user account.



            Type gcloud auth login and access the link you are provided, once there, copy the code and paste it into the command line.



            Then do gsutil mb gs://bucket-name.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 10 at 17:56









            Maxim

            1,259110




            1,259110























                0














                The security model has 2 things at play, API Scopes and IAM permissions. Access is determined by the AND of them. So you need an acceptable scope and enough IAM privileges in order to do whatever action.



                • API Scopes are bound to the credentials. They are represented by a URL like, https://www.googleapis.com/auth/cloud-platform.

                • IAM permissions are bound to the identity. These are setup in the Cloud Console's IAM & admin > IAM section.

                This means you can have 2 VMs with the default service account but both have different levels of access.



                For simplicity you generally want to just set the IAM permissions and use the cloud-platform API auth scope.



                To check if you have this setup go to the VM in cloud console and you'll see something like:




                Cloud API access scopes



                Allow full access to all Cloud APIs




                When you SSH into the VM by default gcloud will be logged in as the service account on the VM. I'd discourage logging in as yourself otherwise you more or less break gcloud's configuration to read the default service account.



                Once you have this setup you should be able to use gsutil properly.






                share|improve this answer

























                  0














                  The security model has 2 things at play, API Scopes and IAM permissions. Access is determined by the AND of them. So you need an acceptable scope and enough IAM privileges in order to do whatever action.



                  • API Scopes are bound to the credentials. They are represented by a URL like, https://www.googleapis.com/auth/cloud-platform.

                  • IAM permissions are bound to the identity. These are setup in the Cloud Console's IAM & admin > IAM section.

                  This means you can have 2 VMs with the default service account but both have different levels of access.



                  For simplicity you generally want to just set the IAM permissions and use the cloud-platform API auth scope.



                  To check if you have this setup go to the VM in cloud console and you'll see something like:




                  Cloud API access scopes



                  Allow full access to all Cloud APIs




                  When you SSH into the VM by default gcloud will be logged in as the service account on the VM. I'd discourage logging in as yourself otherwise you more or less break gcloud's configuration to read the default service account.



                  Once you have this setup you should be able to use gsutil properly.






                  share|improve this answer























                    0












                    0








                    0






                    The security model has 2 things at play, API Scopes and IAM permissions. Access is determined by the AND of them. So you need an acceptable scope and enough IAM privileges in order to do whatever action.



                    • API Scopes are bound to the credentials. They are represented by a URL like, https://www.googleapis.com/auth/cloud-platform.

                    • IAM permissions are bound to the identity. These are setup in the Cloud Console's IAM & admin > IAM section.

                    This means you can have 2 VMs with the default service account but both have different levels of access.



                    For simplicity you generally want to just set the IAM permissions and use the cloud-platform API auth scope.



                    To check if you have this setup go to the VM in cloud console and you'll see something like:




                    Cloud API access scopes



                    Allow full access to all Cloud APIs




                    When you SSH into the VM by default gcloud will be logged in as the service account on the VM. I'd discourage logging in as yourself otherwise you more or less break gcloud's configuration to read the default service account.



                    Once you have this setup you should be able to use gsutil properly.






                    share|improve this answer












                    The security model has 2 things at play, API Scopes and IAM permissions. Access is determined by the AND of them. So you need an acceptable scope and enough IAM privileges in order to do whatever action.



                    • API Scopes are bound to the credentials. They are represented by a URL like, https://www.googleapis.com/auth/cloud-platform.

                    • IAM permissions are bound to the identity. These are setup in the Cloud Console's IAM & admin > IAM section.

                    This means you can have 2 VMs with the default service account but both have different levels of access.



                    For simplicity you generally want to just set the IAM permissions and use the cloud-platform API auth scope.



                    To check if you have this setup go to the VM in cloud console and you'll see something like:




                    Cloud API access scopes



                    Allow full access to all Cloud APIs




                    When you SSH into the VM by default gcloud will be logged in as the service account on the VM. I'd discourage logging in as yourself otherwise you more or less break gcloud's configuration to read the default service account.



                    Once you have this setup you should be able to use gsutil properly.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Nov 11 at 5:28









                    Jeremy Edwards

                    9,955156898




                    9,955156898





















                        0














                        I will suggest you to try add the scope "cloud-platform" to the instance by running the gcloud command below




                        gcloud alpha compute instances set-scopes INSTANCE_NAME [--zone=ZONE]
                        [--scopes=[SCOPE,…] [--service-account=SERVICE_ACCOUNT




                        As a scopes put "https://www.googleapis.com/auth/cloud-platform" since it give Full access to all Google Cloud Platform resources.



                        Here is gcloud documentation






                        share|improve this answer

























                          0














                          I will suggest you to try add the scope "cloud-platform" to the instance by running the gcloud command below




                          gcloud alpha compute instances set-scopes INSTANCE_NAME [--zone=ZONE]
                          [--scopes=[SCOPE,…] [--service-account=SERVICE_ACCOUNT




                          As a scopes put "https://www.googleapis.com/auth/cloud-platform" since it give Full access to all Google Cloud Platform resources.



                          Here is gcloud documentation






                          share|improve this answer























                            0












                            0








                            0






                            I will suggest you to try add the scope "cloud-platform" to the instance by running the gcloud command below




                            gcloud alpha compute instances set-scopes INSTANCE_NAME [--zone=ZONE]
                            [--scopes=[SCOPE,…] [--service-account=SERVICE_ACCOUNT




                            As a scopes put "https://www.googleapis.com/auth/cloud-platform" since it give Full access to all Google Cloud Platform resources.



                            Here is gcloud documentation






                            share|improve this answer












                            I will suggest you to try add the scope "cloud-platform" to the instance by running the gcloud command below




                            gcloud alpha compute instances set-scopes INSTANCE_NAME [--zone=ZONE]
                            [--scopes=[SCOPE,…] [--service-account=SERVICE_ACCOUNT




                            As a scopes put "https://www.googleapis.com/auth/cloud-platform" since it give Full access to all Google Cloud Platform resources.



                            Here is gcloud documentation







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Nov 13 at 20:37









                            Alioua

                            554110




                            554110



























                                draft saved

                                draft discarded
















































                                Thanks for contributing an answer to Stack Overflow!


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid


                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.

                                To learn more, see our tips on writing great answers.





                                Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                Please pay close attention to the following guidance:


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid


                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.

                                To learn more, see our tips on writing great answers.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function ()
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53184334%2frecovering-access-after-initially-provisioning-wrong-scopes-for-an-instance%23new-answer', 'question_page');

                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown







                                Popular posts from this blog

                                How to how show current date and time by default on contact form 7 in WordPress without taking input from user in datetimepicker

                                Darth Vader #20

                                Ondo