You may be accustomed to assigning roles to ordinary user, but if you try to assign a similar role to a service account, you may see this error:
cf set-space-role generic_client <MY ORG> <MY SPACE> --client
Assigning role SpaceDeveloper to user generic_client in org <MY ORG> / space <MY SPACE> as admin ....
You are not authorized to perform the requested action.
FAILED.
If you attempt this with the -v (verbose) option, you may see the following:
REQUEST:
GET /oauth/clients/generic_client
RESPONSE:
HTTP/1.1 403 Forbidden
error: Insufficient_scope
error_description: insufficient scope for this resource
scope: "uaa.admin, clients.read, clients.admin, zones.uaa.admin"
The following command should reveal that the admin user does indeed lack the scopes above (uaa.admin, clients.read, clients.admin, zones.uaa.admin):
uaa get-user admin | jq -re '.groups | sort_by(.display)[].display' Tanzu Application Service (TAS, all versions)
A verified workaround that enables you to assign roles to service accounts is to add clients.read to the cf client scopes and add the admin account to the clients.read group (uaac member add clients.read admin). Subscribe to this article to receive updates on the issue being fixed in a new release of Tanzu Application Service.
cf login -a <API_ENDPOINT> -u <ADMIN_USERNAME> -p <PASSWORD> --skip-ssl-validation
bash
cf curl /v2/users/$(cf user-guid)/permissions
If you’re modifying an existing client, retrieve its details using the UAA CLI (uaac):
uaac target <UAA_ENDPOINT>
uaac token client get <ADMIN_CLIENT_ID> -s <ADMIN_CLIENT_SECRET>
uaac clients
uaac client update <CLIENT_ID> --scope "existing.scope clients.read"
uaac client update my-client --scope "cloud_controller.read clients.read"
uaac client add <CLIENT_ID> \
--name <CLIENT_NAME> \
--secret <CLIENT_SECRET> \
--scope "clients.read" \
--authorized_grant_types "client_credentials" \
--authorities "clients.read"