Surya Kasturi
Surya Kasturi

Reputation: 4731

Google Cloud Resource Manager API - grant owner role to a user

I am using Google Cloud Resource Manager API with Service Account authorization in Google Apps Script. In the program I am interested in updating the roles of a Developer Console Project.

Specifically, I am trying to change Developer Console project's owner to editor and another user as owner. This, I believe in terms of HTTP Request payload would look like:

// before (taken from response of getIamPolicy REST call)
{
    "bindings": [{
            "role": "roles/owner",
            "members": ["user:[email protected]"]
     }],
    "version": "0",
    "etag": "acbqwcada="
}

// after (modified policy) used in setIamPolicy REST call
{
    "bindings": [{
            "role": "roles/owner",
            "members": ["user:[email protected]"]
     },
     {
            "role": "roles/editor",
            "members": ["user:[email protected]"]
     }],
    "version": "0",
    "etag": "acbqwcada="
}

Few things I observed:

Upvotes: 3

Views: 1688

Answers (1)

Zack Butcher
Zack Butcher

Reputation: 1086

The Cloud Resource Manager API does not support adding an owner via setIamPolicy, see the documentation on setIamPolicy:

To be added as an owner, a user must be invited via Cloud Platform console and must accept the invitation.

After you've invited [email protected] and they've accepted (they'll appear as an owner of the project in the Cloud Platform console, and also as a member of the owner binding returned by getIamPolicy) you can make the setIamPolicy call to make [email protected] an editor.

Upvotes: 2

Related Questions