---
title: "Comment by G White on \"Securing Your FastAPI with API Key Authentication: A Step-by-Step Guide\" | Hashnode"
description: "Hello, I have a question about the function verify_api_key()... Underneath the comment &quot;#verifying extract ..... the prefix&quot;, we then verify the corre"
url: "https://hashnode.com/posts/securing-your-fastapi-with-api-key-authentication-a-step-by-step-guide/6454e99f6c5f0bc0d2246389/comment/64e4ddab3ca789daeb378502"
---

[Discussion](https://hashnode.com/posts/securing-your-fastapi-with-api-key-authentication-a-step-by-step-guide/6454e99f6c5f0bc0d2246389)

Comment [Securing Your FastAPI with API Key Authentication: A Step-by-Step Guide](https://hashnode.com/posts/securing-your-fastapi-with-api-key-authentication-a-step-by-step-guide/6454e99f6c5f0bc0d2246389)

[G White](https://hashnode.com/@grawfin)

[Aug 22, 2023](https://hashnode.com/posts/securing-your-fastapi-with-api-key-authentication-a-step-by-step-guide/6454e99f6c5f0bc0d2246389/comment/64e4ddab3ca789daeb378502)

Hello, I have a question about the function verify\_api\_key()...

Underneath the comment "#verifying extract ..... the prefix", we then verify the corresponding hashed\_api\_key with the function verify\_hashed\_key().

Can you explain why this step is necessary / preferred? As I understand, we only reach this step if the secret\_key the user sent in the Header() was found in the database, and therefore it seems it should be enough to simply return the corresponding user\_id, before we ever run the verify\_hashed\_key() function.

I would greatly appreciate any insight here, thank you!

[Edwin Ayabie](https://hashnode.com/@madvirus)

[Aug 22, 2023](https://hashnode.com/posts/securing-your-fastapi-with-api-key-authentication-a-step-by-step-guide/6454e99f6c5f0bc0d2246389/comment/64e4ddab3ca789daeb378502#reply-64e4e0893ca789daeb37856e)

it is just an added verification i like to do, you can simply modify/ignore the part you do not really need

[G White](https://hashnode.com/@grawfin)

[Aug 22, 2023](https://hashnode.com/posts/securing-your-fastapi-with-api-key-authentication-a-step-by-step-guide/6454e99f6c5f0bc0d2246389/comment/64e4ddab3ca789daeb378502#reply-64e4e495bdabeadbcf84fb96)

[Edwin Ayabie](https://hashnode.com/@madvirus) Understood, thanks!

[Edwin Ayabie](https://hashnode.com/@madvirus)

[Aug 22, 2023](https://hashnode.com/posts/securing-your-fastapi-with-api-key-authentication-a-step-by-step-guide/6454e99f6c5f0bc0d2246389/comment/64e4ddab3ca789daeb378502#reply-64e504d0bdabeadbcf84ffea)

[G White](https://hashnode.com/@grawfin) Glad you found it helpful
