# Scripting API queries without hardcoded access token in the script

**URL:** <https://community.dynatrace.com/t/scripting-api-queries-without-hardcoded-access-token-in-the-script/39946>\
**Category:** Dynatrace API\
**Tags:** data-privacy-and-product-security, tokens, dynatrace-api\
**Created:** [May 26, 2023, 7:37pm UTC](https://community.dynatrace.com/t/scripting-api-queries-without-hardcoded-access-token-in-the-script/39946 "2023-05-26T19:37:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jdport](https://avatars.discourse-cdn.com/v4/letter/j/ce73a5/32.png) [@jdport](https://community.dynatrace.com/u/jdport)\
**Post date:** [May 26, 2023, 7:37pm UTC](https://community.dynatrace.com/t/scripting-api-queries-without-hardcoded-access-token-in-the-script/39946/1 "2023-05-26T19:37:27Z")

</div>

Hello,

I’ve written several scripts for various tasks with the Dynatrace API but updated security requirements are going to be prohibiting me from having our API token hard coded in the script.&nbsp; &nbsp; &nbsp;I was wondering how others have dealt with this… how I can pass a credential to the API without having it in the actual script that would satisfy our security team.

Thanks in advance for any thoughts on this.

-Jeff

---

<div class="post-metadata">

**Author:** ![AntonPineiro](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/antonpineiro/32/49_2.png) [@AntonPineiro](https://community.dynatrace.com/u/AntonPineiro)\
**Post date:** [May 27, 2023, 2:11pm UTC](https://community.dynatrace.com/t/scripting-api-queries-without-hardcoded-access-token-in-the-script/39946/2 "2023-05-27T14:11:49Z")

</div>

Hi,

Maybe you can use environment variables or asking token in prompt.

Best regards

---

<div class="post-metadata">

**Author:** ![alexander\_dt](https://avatars.discourse-cdn.com/v4/letter/a/5daacb/32.png) [@alexander\_dt](https://community.dynatrace.com/u/alexander_dt)\
**Post date:** [June 1, 2023, 1:36pm UTC](https://community.dynatrace.com/t/scripting-api-queries-without-hardcoded-access-token-in-the-script/39946/3 "2023-06-01T13:36:28Z")

</div>

I’d second&nbsp;[@AntonPineiro](https://community.dynatrace.com/user/58682)’s response. If it’s an interactive application, prompting the user is probably the safest approach. Otherwise, environment variables are also often used in this context (of course, you’ll still need to make sure those are secure as well) or reading the values from a (possibly encrypted) database or configuration file.
