From the course: Creating GPTs with Actions

Unlock the full course today

Join today to access over 24,700 courses taught by industry experts.

Solution: Secure your action

Solution: Secure your action - ChatGPT Tutorial

From the course: Creating GPTs with Actions

Solution: Secure your action

(playful music) - [Instructor] How did you enjoy the challenge? Let's see how I solved it. The first step is to generate a security token. This key can be anything, though you will likely want a randomly generated sequence. Feel free to use any method to randomly generate a key. Now let's look at our Python API code. You'll need to add that key to your file. Notice here on line 16, I have created the SERVICE_AUTH_KEY variable and hard coded the key. Hard coding the auth token here is fine for local developer testing, but before moving this code to production or even checking it into version control like GitHub, you'll want to use a more secure mechanism for storing this key, like using an environment variable. Next, you'll need to ensure that all callers of the API enter this authorization header whenever calling your API. So let's scroll down here. On line 20, I've added this function called assert_auth_header, and we will call it in each function request. So if the person or the…

Contents