anyone succeeded in acquiring temporary

anyone succeeded in acquiring temporary access credentials?
1 Reply
Fake User
Fake User5mo ago
Agreed, the docs for the Cloudflare api are a bit scuffed. This is working for me though.
const options = {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-Auth-Email": `${process.env.X_AUTH_EMAIL}`,
"X-Auth-Key": `${process.env.X_AUTH_KEY}`
},
body: `{
"bucket": "${process.env.BUCKET_NAME}",
"parentAccessKeyId": "${process.env.R2_ACCESS_KEY_ID}",
"permission": "object-read-only",
"ttlSeconds": 3600
}`
};

fetch(`https://api.cloudflare.com/client/v4/accounts/${process.env.ACCOUNT_ID}/r2/temp-access-credentials`, options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));
const options = {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-Auth-Email": `${process.env.X_AUTH_EMAIL}`,
"X-Auth-Key": `${process.env.X_AUTH_KEY}`
},
body: `{
"bucket": "${process.env.BUCKET_NAME}",
"parentAccessKeyId": "${process.env.R2_ACCESS_KEY_ID}",
"permission": "object-read-only",
"ttlSeconds": 3600
}`
};

fetch(`https://api.cloudflare.com/client/v4/accounts/${process.env.ACCOUNT_ID}/r2/temp-access-credentials`, options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));
X_AUTH_EMAIL is your cf account email X_AUTH_KEY you can use your Global API Key BUCKET_NAME is the name of the bucket you're making a credential for R2_ACCESS_KEY_ID, is the id of a valid r2 api token you've already made.
Want results from more Discord servers?
Add your server