API support for creating R2 S3 credentials

I need to dynamically create S3 style credentials (i.e. api key and key secret combo) to enable writes to a dynamically created R2 bucket. I'm looking to use the API to create these. I've successfully created a bucket using the API and an auth token configured with the R2 edit permission. I have not been able to create the S3 style credentials using the API, however. This interface looks promising: https://developers.cloudflare.com/api/operations/user-api-tokens-create-token However, the result does not contain (at least per the docs) the S3 creds - it only contains the token value. ALSO, I'm unable to configure an auth token with the permission to use this API call in the first place. Under https://dash.cloudflare.com/profile/api-tokens I can add permissions for a token. However, I don't see a permission that allows editing/creating API tokens. To summarize: 1. How can I use the API to create an API token? This requires granting permission for this, which I haven't been able to do. 2. How can I create an API token that returns S3 style credentials for editing an R2 bucket?
Cloudflare API Documentation
Interact with Cloudflare's products and services via the Cloudflare API
2 Replies
Garrett
GarrettOP10mo ago
Update: I just spotted the "Create Additional Tokens" template for creating a token and indeed "User -> API Tokens -> Edit" permission is pre-populated. This option is NOT, however, available in the UI when otherwise adding a new token. I've attached a screen shot.
No description
Garrett
GarrettOP10mo ago
@Leo - ah very helpful! Where might I find the S3 api key in that case? Sorry - I missed the reference to the #r2 post there. @Leo I'd like to make a feature request/recommendation to the API team to modify their call to create token to return the S3 credentials - what channel should I post that to?
Want results from more Discord servers?
Add your server