Skip to content

Commit 126785c

Browse files
committed
Update Cloudflaire Turnstile instructions
1 parent 43b08ec commit 126785c

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

README.md

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,27 @@ That's it! **Happy verifying!** :tada:
259259

260260
After following the [instructions](https://developers.cloudflare.com/turnstile/get-started/) to get the client ready, and to generate your secret key, verifying the resposne on the server side is easy.
261261

262+
#### Client Side
263+
264+
More detailed instructions, including theming, can be found at
265+
[https://developers.cloudflare.com/turnstile/get-started/](https://developers.cloudflare.com/turnstile/get-started/).
266+
267+
In short, you want to include the JavaScript in the `<head>`:
268+
269+
```html
270+
<script src="https://challenges.cloudflare.com/turnstile/v0/api.js" async defer></script>
271+
```
272+
273+
And then insert the widget:
274+
275+
```html
276+
<div class="cf-turnstile" data-sitekey="your-sitekey" data-action="example-action"></div>
277+
```
278+
279+
The *data-action* attribute can be verified later, on the server side.
280+
281+
#### Server Side
282+
262283
```csharp
263284
// 1. Get the client IP address in your chosen web framework
264285
string clientIp = GetClientIpAddress();
@@ -284,9 +305,17 @@ else{
284305
}
285306
```
286307

287-
The full response, including `cdata`, can be fetched using `captchaApi.Response2Async(capthcaResponse, clientIp, secret)`.
308+
The *hostname* and *action* can be (and **should** be) verified by passing the `hostname` and `action` arguments to `captchaApi.Verify2Async`, for example:
288309

289-
Furthermore, the *hostname* and *action* can be (and **should** be) verified by passing the `hostname` and `action` arguments to `captchaApi.Verify2Async`.
310+
```csharp
311+
var isValid = await captchaApi.Verify2Async(
312+
capthcaResponse, clientIp, secret,
313+
hostname: "expected.hostname",
314+
action: "example-action",
315+
);
316+
```
317+
318+
The full response, including `cdata`, can be fetched using `captchaApi.Response2Async(capthcaResponse, clientIp, secret)`.
290319

291320

292321
Building

0 commit comments

Comments
 (0)