> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://uploadcare.com/docs/llms.txt.

# Security and authentication options

> File Uploader options: security and authentication.

Options for signed uploads, authenticated requests, and secure delivery of uploaded files.

Related guides: [File Uploader security](/docs/file-uploader/security/), [Secure uploads](/docs/security/secure-uploads/), [Secure delivery](/docs/security/secure-delivery/).

See [all options](/docs/file-uploader/options/) for the full list.

### authToken Since v1.35.1 \[#auth-token]

A token for [signed uploads](/docs/security/secure-uploads/), sent with every
Upload API request. Needs File Uploader 1.35.1 or later. Versions that predate
the option ignore it without a warning and the upload goes out unsigned.

Pass a function and the uploader caches the token and replaces it 30 seconds
before it expires, and retries an upload once with a new token when Uploadcare
refuses the old one as expired or spent. A new function on each render, as in React,
keeps the cached token. A plain token gets neither: it is sent as given, never
refreshed and never retried, so its lifetime must cover the whole upload. Leave
it unset to upload without a token. A function that returns nothing fails the
upload with an `AUTH_TOKEN_ERROR`.

A `{ getToken, invalidate }` object works in place of the function when you
keep your own cache. An [`AuthTokenCache`](https://github.com/uploadcare/uploadcare-js-api-clients/tree/master/packages/signed-uploads#caching-the-token-in-the-browser) instance is already
this shape, so you can pass one straight in. The uploader then adds none of
its own and calls your `invalidate()` when a token is refused.

Takes precedence over `secureSignature`, `secureExpire` and
`secureUploadsSignatureResolver`, which are dropped when it is set.

With [React File Uploader](/docs/integrations/react-file-uploader/) this is an
ordinary prop, function and all. On the web component, a function has to be set
as a [DOM property](/docs/file-uploader/configuration/#how-to-define-dom-properties)
rather than an attribute. The `auth-token` attribute carries a plain token only,
and writing it after setting a function replaces the function.

[Signed uploads](/docs/security/secure-uploads/) covers issuing the
tokens, and [`invalidateAuthToken()`](/docs/file-uploader/api/#invalidate-auth-token)
drops a cached one.

> **Note**
>
> **Note:** Replacing a token early needs a readable `exp`. A token the
> uploader cannot parse is cached and never refreshed on its own, so invalidate
> it yourself.

Attribute: `auth-token`

DOM property: `authToken`

Type: `string | (() => string | Promise<string>) | { getToken, invalidate } | null`

Default: `null`

### secureSignature \[#secure-signature]

Set `signature` for signed uploads. See the
[signature reference](/docs/api/upload/authentication/#signature) for details,
or [`authToken`](#auth-token) for the token scheme recommended for new
integrations.

Attribute: `secure-signature`

DOM property: `secureSignature`

Type: `string`

Default: `''`

### secureExpire \[#secure-expire]

Set `expire` for signed uploads. See the
[signature reference](/docs/api/upload/authentication/#signature) for details.

Attribute: `secure-expire`

DOM property: `secureExpire`

Type: `string`

Default: `''`

### secureUploadsSignatureResolver Since v0.41.0 \[#secure-uploads-signature-resolver]

Works as [DOM property](/docs/file-uploader/configuration/#how-to-define-dom-properties) only.

Set a function that resolves signed uploads `signature` and
`expire` asynchronously.

This function will be called before each upload request in case when previous
`signature` and `expire` are not set or expired.

There are a 10 minutes threshold for the `expire` value. If the `expire` value
will be expired in 10 minutes, it will be considered as expired and a new value
will be requested.

See [security](/docs/file-uploader/security/#secure-uploading) and the [signature reference](/docs/api/upload/authentication/#signature) for details.

Attribute: `-`

DOM property: `secureUploadsSignatureResolver`

Type: `() => Promise<{ secureSignature: string; secureExpire: string } | null>`

Default: `null`

### secureUploadsExpireThreshold Since v0.41.0 \[#secure-uploads-expire-threshold]

Works together with the `secureUploadsSignatureResolver` option.
Sets the auto-refreshing threshold for signed uploads `expire` value in milliseconds.

> **Note**
>
> **Note:** This applies to signatures only. An [`authToken`](#auth-token) is replaced by the uploader's own cache 30 seconds before the token expires, and this option has no effect on it.

The `expire` value will be considered expired if the difference between the current
time and the `expire` value is less than the threshold. In this case,
a new `signature` and `expire` will be requested using the `secureUploadsSignatureResolver` function.

This is needed to prevent the `expire` value from expiring during the direct uploading method.
Files less than 25 MB are uploaded directly to the Uploadcare servers, and the `expire` value will
be checked after the file is uploaded, so it should be valid during the whole upload process.

Files larger than 25 MB are uploaded using the multipart upload method, and the `expire` value will be checked before the upload starts.

See [security](/docs/file-uploader/security/#secure-uploading) and the [signature reference](/docs/api/upload/authentication/#signature) for details.

Attribute: `secure-uploads-expire-threshold`

DOM property: `secureUploadsExpireThreshold`

Type: `number`

Default: `10 * 60 * 1000` (10 minutes)

### secureDeliveryProxy \[#secure-delivery-proxy]

Set a proxy URL template. See [secure delivery](/docs/file-uploader/security/#secure-delivery-proxy)
docs for details.

Attribute: `secure-delivery-proxy`

DOM property: `secureDeliveryProxy`

Type: `string`

Default: `''`

### secureDeliveryProxyUrlResolver Since v0.41.0 \[#secure-delivery-proxy-url-resolver]

Works as [DOM property](/docs/file-uploader/configuration/#how-to-define-dom-properties) only.

Set a function that resolves the secure delivery proxy URL. It accepts the
`previewUrl` and `urlParts` arguments and should return the resolved URL itself
or a promise that resolves that URL.

Argument `urlParts` is an object with the deserialized URL parts:

* `uuid`: file UUID.
* `cdnUrlModifiers`: CDN URL modifiers (`-/resize/100x/` or `''` for example).
* `fileName`: file name (`'example.jpg'` or `''` for example).

See [secure delivery](/docs/file-uploader/security/#secure-delivery-proxy) docs for details.

Attribute: `-`

DOM property: `secureDeliveryProxyUrlResolver`

Type:
`(previewUrl: string, urlParts: { uuid: string; cdnUrlModifiers: string; fileName: string }) => Promise<string> | string`

Default: `null`