R2 programmatically create token
You need to generate via the R2 Tab -> "Manage R2 API Tokens"
8 Replies
I want to create via the API because it's a part of the deployment service. Is that not possible?
very possible
The Access Key is the ID of the token
The Secret is the sha256sum of the token value
echo -n "token" | sha256sum
Sorry I am not sure I understand.
I need to create one set of credentials per bucket via the API.
You can see what the manage r2 api tokens does to create a bucket scoped one
it's using the same create token endpoint https://developers.cloudflare.com/api/operations/user-api-tokens-create-token
Cloudflare API Documentation
Interact with Cloudflare's products and services via the Cloudflare API
if you're confused: play around with the dashboard w/ network tools open, it uses the same create token endpoint. You can see how you can create scoped tokens via it, and then you just take the ID for the Access Key and the Secret Key is sha256sum the api token value/secret
Cloudflare Docs
Authentication | Cloudflare R2 docs
You can generate an API token to serve as the Access Key for usage with existing S3-compatible SDKs or XML APIs.
Okay got it. Thanks