# Secure a FastAPI Server with Auth0 - Invalid User

**URL:** <https://community.auth0.com/t/secure-a-fastapi-server-with-auth0-invalid-user/81386>\
**Category:** JWT.io\
**Tags:** fastapi, jwt, error\
**Created:** [April 7, 2022, 4:15pm UTC](https://community.auth0.com/t/secure-a-fastapi-server-with-auth0-invalid-user/81386 "2022-04-07T16:15:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![JaimeFabian](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jaimefabian/32/36468_2.png) [@JaimeFabian](https://community.auth0.com/u/JaimeFabian)\
**Post date:** [April 7, 2022, 4:15pm UTC](https://community.auth0.com/t/secure-a-fastapi-server-with-auth0-invalid-user/81386/1 "2022-04-07T16:15:57Z")

</div>

Hi everyone,

I’m setting up a server with FastAPI and I want to secure its endpoints using Auth0.

I’ve followed and implemented this article [Build and Secure FastAPI Server with Auth0](https://auth0.com/blog/build-and-secure-fastapi-server-with-auth0/) and also this video [How to Protect an API in FastAPI with Auth0](https://www.youtube.com/watch?v=ZSzzpnsOdrA).

Right now, if I want to test the configured API in Auth0 requesting a token with my client id and client secret, I receive the following error back:

```auto
{'status': 'error', 'message': 'Invalid issuer'}

```

I’ve verified the token in [jwt.io](http://jwt.io) and looks correct and also verified my domain, api audience, issuer, and algorithms variables and can’t see any issues.

I haven’t found further information to this error and that’s why I’m posting this here. Hopefully someone could help me or if anybody has any ideas, I would appreciate it very much!

Best regards,  
Jaime

---

<div class="post-metadata">

**Author:** ![cellador](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@cellador](https://community.auth0.com/u/cellador)\
**Post date:** [February 6, 2023, 12:57pm UTC](https://community.auth0.com/t/secure-a-fastapi-server-with-auth0-invalid-user/81386/2 "2023-02-06T12:57:49Z")

</div>

Hey Jaime,

it’s been a while since you posted but I just ran into the same issue and found a solution. Maybe this can be of help for people encountering the same:

Take your bearer token, decode it on [https://jwt.io/](https://jwt.io/) and check the `iss` payload value. The issuer parameter that you use to set up your PyJWK client with has to match that value exactly. I was missing a `/` at the end of the string.

Hope that helps,  
Best regards.

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [February 6, 2023, 1:34pm UTC](https://community.auth0.com/t/secure-a-fastapi-server-with-auth0-invalid-user/81386/3 "2023-02-06T13:34:47Z")

</div>

Thanks for sharing that with the rest of community!

---

<div class="post-metadata">

**Author:** ![dan-auth0](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@dan-auth0](https://community.auth0.com/u/dan-auth0)\
**Post date:** [February 16, 2023, 11:04pm UTC](https://community.auth0.com/t/secure-a-fastapi-server-with-auth0-invalid-user/81386/4 "2023-02-16T23:04:07Z")

</div>

If you run into issues like this in the future, you can also [build a custom full-stack code sample](https://developer.auth0.com/resources/code-samples/full-stack) to troubleshoot full-stack issues like this. 💪

---

<div class="post-metadata">

**Author:** ![JaimeFabian](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jaimefabian/32/36468_2.png) [@JaimeFabian](https://community.auth0.com/u/JaimeFabian)\
**Post date:** [February 17, 2023, 7:45am UTC](https://community.auth0.com/t/secure-a-fastapi-server-with-auth0-invalid-user/81386/5 "2023-02-17T07:45:50Z")

</div>

Hi cellador! Thanks for your reply. I’m not able to test your suggestion currently since we went for a custom implementation on our side but for a new project I will definitely try this 😃

Thanks for sharing!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [March 3, 2023, 7:46am UTC](https://community.auth0.com/t/secure-a-fastapi-server-with-auth0-invalid-user/81386/6 "2023-03-03T07:46:19Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
