Skip to content

Commit 4245d0c

Browse files
committed
Not hashing twice
1 parent 48ae5d7 commit 4245d0c

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/content/docs/r2/examples/authenticate-r2-auth-tokens.mdx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pcx_content_type: Example
55

66
import { Tabs, TabItem } from '~/components';
77

8-
The following example shows how to authenticate against R2 using the S3 API and an API token.
8+
The following example shows how to authenticate against R2 using the S3 API and an API token.
99

1010
:::note
1111
For providing secure access to bucket objects for anonymous users, we recommend using [pre-signed URLs](/r2/api/s3/presigned-urls/) instead.
@@ -39,14 +39,11 @@ export R2_BUCKET_NAME=your_bucket_name
3939
const SECRET_ACCESS_KEY = process.env.R2_SECRET_ACCESS_KEY;
4040
const BUCKET_NAME = process.env.R2_BUCKET_NAME;
4141

42-
// Hash the secret access key
43-
const hashedSecretKey = crypto.createHash('sha256').update(SECRET_ACCESS_KEY).digest('hex');
44-
4542
// Configure the S3 client for Cloudflare R2
4643
const s3Client = new AWS.S3({
4744
endpoint: `https://${ACCOUNT_ID}.r2.cloudflarestorage.com`,
4845
accessKeyId: ACCESS_KEY_ID,
49-
secretAccessKey: hashedSecretKey,
46+
secretAccessKey: SECRET_ACCESS_KEY,
5047
signatureVersion: 'v4',
5148
region: 'auto' // Cloudflare R2 doesn't use regions, but this is required by the SDK
5249
});
@@ -233,4 +230,3 @@ export R2_BUCKET_NAME=your_bucket_name
233230
```
234231
</TabItem>
235232
</Tabs>
236-

0 commit comments

Comments
 (0)