Permission denied error with Cloud Datastore
bwnyasse opened this issue · 1 comments
Description:
I encountered a Permission denied error while executing my test code to interact with Cloud Datastore. I have assigned the owner role to the service account used for authentication. However, I am still unable to access the Datastore resources and perform operations within the project. I would appreciate any assistance in resolving this issue.
What I am doing in my app:
- Load the service account credentials from the file.
- Authenticate the client using the service account credentials and the necessary scopes (datastore.Datastore.Scopes).
- Execute the loadStockConfiguration() function, which internally uses the DatastoreDB and dbService.commit methods.
- Observe the Permission denied error with the following stack trace:
Unhandled exception:
DetailedApiRequestError(status: 403, message: Permission denied on resource project learning-sandbox.)
#0 validateResponse (package:_discoveryapis_commons/src/api_requester.dart:306:9)
<asynchronous suspension>
dart-lang/labs#16 ApiRequester.request (package:_discoveryapis_commons/src/api_requester.dart:72:16)
<asynchronous suspension>
dart-lang/labs#17 ProjectsResource.commit (package:googleapis/datastore/v1.dart:193:23)
<asynchronous suspension>
dart-lang/labs#18 DatastoreImpl.commit.<anonymous closure> (package:gcloud/src/datastore_impl.dart:354:57)
<asynchronous suspension>
Additional Context:
- The service account assigned to the code has the owner role.
- Here is my wip
Any guidance or assistance in resolving this issue related to Cloud Datastore would be greatly appreciated.
I was able to make it work.
The documentation suggests instantiating the DatastoreDB object using the project name prefixed with s~, like this:
var db = new DatastoreDB(
new datastore.Datastore(client, 's~my-project'));
However, I discovered that removing the s~ and using the project ID instead of the project name resolved the issue for me. Therefore, I suggest updating the documentation to clarify that the project ID should be used instead of the project name.
var db = new DatastoreDB(
new datastore.Datastore(client, 'my-project-id'));