As a gadget user I want statements created with my tool by a logged-in user to be attributed to that user so that the user gets credit for their contributions.
As a wiki administrator I want user permission to be taken into account so that illegal edits are not possible.
Bearer token authorization using Authorization HTTP header is to be used.
In case of authentication errors, including not having permission to create a statement, behaviour consistent with GET routes of Wikibase REST API, and with Mediawiki REST API is to be used, even if it was not 100% correct (e.g. using 403 response code instead of 401, or the other way round).
Note that 2020 Wikibase REST API proposal suggests responding with HTTP 501 or 503 in case of authentication errors which seems not correct.
No Wikibase-specific permissions have to be checked, but the user needs to have edit permissions. Make sure that *protected* items are also checked correctly.