# Generate a captcha token in the pre-request script

**URL:** <https://community.postman.com/t/generate-a-captcha-token-in-the-pre-request-script/46862>\
**Category:** Help Hub\
**Tags:** scripts, pre-request-script, postman-sandbox\
**Created:** [April 27, 2023, 7:29pm UTC](https://community.postman.com/t/generate-a-captcha-token-in-the-pre-request-script/46862 "2023-04-27T19:29:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aviation-operator-13](https://avatars.discourse-cdn.com/v4/letter/a/bbce88/32.png) [@aviation-operator-13](https://community.postman.com/u/aviation-operator-13)\
**Post date:** [April 27, 2023, 7:29pm UTC](https://community.postman.com/t/generate-a-captcha-token-in-the-pre-request-script/46862/1 "2023-04-27T19:29:18Z")

</div>

_My question_:  
Is it possible to access browser APIs in the pre-request script?

My first pass at this is pretty much a hard no. We are protecting some of our public endpoints with a reCaptcha v3 and I was thinking it’d be neat to have a pre-request script generate a token for me automatically. Alas, the reCaptcha requires browser APIs like window and createElement().

_I’ve already tried_:  
Mocking some browser APIs in the pre-request script but this seems like a very cumbersome route to go down. I am thinking it would need to be more like an update to the pre-request script runner itself to provide access to Browser APIs

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [April 3, 2024, 1:53pm UTC](https://community.postman.com/t/generate-a-captcha-token-in-the-pre-request-script/46862/2 "2024-04-03T13:53:33Z")

</div>


