Skip to content

Commit 540ca2d

Browse files
committed
chore: updated docs
1 parent e90ba12 commit 540ca2d

File tree

1 file changed

+67
-1
lines changed

1 file changed

+67
-1
lines changed

sources/platform/collaboration/general-resource-access.md

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ The default setting strikes a good balance for casual or internal use, but **Res
4747
You can switch to **Restricted** access at any time. If it causes issues in your workflow, you can revert to the default setting just as easily.
4848

4949
:::note Support in public Actors
50+
5051
Because this is a new setting, some existing public Actors and integrations might not support it yet. Their authors need to update them to provide a valid token on all API calls.
52+
5153
:::
5254

5355

@@ -260,11 +262,75 @@ To test your public Actor, run it using an account with **General resource acces
260262

261263
:::
262264

263-
In practice, this means that all API calls originating from the Actor need to have a valid API token. If you are using Apify SDK, this should be the default behavior.
265+
In practice, this means that:
266+
- All API requests made by your Actor must include a valid API token.
267+
- When using the Apify SDK or Apify Client, this is handled automatically.
268+
- Avoid relying on URLs that require unrestricted access or authentication by default.
264269

265270

266271
:::caution Actor Runs Inherit User Permissions
267272

268273
Keep in mind that when users run your public Actor, the Actor makes API calls under the user account, not your developer account. This means that it follows the **General resource access** configuration of the user account. The configuration of your developer account has no effect on the Actor users.
269274

270275
:::
276+
277+
### How to migrate Actors to support **Restricted** general resource access
278+
This section provides a practical guide and best practices to help you update your public Actors so they fully support **Restricted general resource access**.
279+
280+
---
281+
282+
#### 1. Always authenticate API requests
283+
284+
All API requests from your Actor should use authenticated methods.
285+
When using the [Apify SDK](https://docs.apify.com/sdk/js/) or [Apify Client](https://docs.apify.com/api/client/js/), this is done automatically.
286+
287+
If your Actor makes direct API calls, include the API token manually:
288+
```js
289+
const response = await fetch(`https://api.apify.com/v2/key-value-stores/${storeId}`, {
290+
headers: { Authorization: `Bearer ${process.env.APIFY_TOKEN}` },
291+
});
292+
```
293+
294+
#### 2. Generate pre-signed URLs for external sharing
295+
If your Actor outputs or shares links to storages (such as datasets or key-value store records), make sure to generate pre-signed URLs instead of hardcoding API URLs.
296+
297+
Pre-signed URLs allow secure, tokenless access for external users.
298+
299+
For example:
300+
301+
```js
302+
import { ApifyClient } from "apify-client";
303+
304+
// ❌ Avoid hardcoding raw API URLs
305+
const recordUrl = `https://api.apify.com/v2/key-value-stores/${storeId}/records/${recordKey}`;
306+
307+
// ✅ Use Apify Client methods instead
308+
const kvStore = client.keyValueStore(storeId);
309+
const recordUrl = kvStore.getRecordPublicUrl(recordKey);
310+
311+
// Save pre-signed URL — accessible without authentication
312+
await Actor.pushData({ recordUrl });
313+
```
314+
315+
For details on how to generate pre-signed URLs, see the section
316+
👉 [Sharing restricted resources with pre-signed URLs](/platform/collaboration/general-resource-access#pre-signed-urls).
317+
318+
:::note Using Console URLs
319+
320+
Datasets and key-value stores also include a `consoleUrl` property.
321+
Console URLs provide stable links to the resource’s page in Apify Console.
322+
Unauthenticated users will be prompted to sign in, ensuring they have required permissions.
323+
324+
:::
325+
326+
#### Test your Actor under restricted access
327+
Before publishing or updating your Actor, it’s important to verify that it works correctly for users with **restricted general resource access**.
328+
329+
You can easily test this by switching your own account’s setting to **Restricted**, or by creating an organization under your account and enabling restricted access there. This approach ensures your tests accurately reflect how your public Actor will behave for end users.
330+
331+
:::tip Make sure links work as expected
332+
333+
Once you’ve enabled restricted access, run your Actor and confirm that all links generated in logs, datasets, key-value stores, and status messages remain accessible as expected. Make sure any shared URLs - especially those stored in results or notifications — work without requiring an API token.
334+
335+
:::
336+

0 commit comments

Comments
 (0)