# Best practice on handling aud claims?

**URL:** <https://community.auth0.com/t/best-practice-on-handling-aud-claims/78469>\
**Category:** Get Help\
**Tags:** claims, jwt\
**Created:** [February 17, 2022, 11:41am UTC](https://community.auth0.com/t/best-practice-on-handling-aud-claims/78469 "2022-02-17T11:41:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![martinbean](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/martinbean/32/33197_2.png) [@martinbean](https://community.auth0.com/u/martinbean)\
**Post date:** [February 17, 2022, 11:41am UTC](https://community.auth0.com/t/best-practice-on-handling-aud-claims/78469/1 "2022-02-17T11:41:01Z")

</div>

I’m started using JWT-based authorisation in my applications, as I have various applications that need to talk to each other and don’t want the overhead of OAuth and constantly bouncing users around to authorise apps.

I have the reason and verifying of JWTs working in my apps, expect for handling the `aud` claim. My intention was, to use the hostname of each service as the `aud`, which leads me to my question.

If I have a service at `foo.example.com` and someone tries to authenticate using a JWT with the `aud` claim set to `bar.example.com`, what HTTP response should I return? Would this be a 400 Bad Request? 401 Unauthorized? Is there a standard response for, “Your token is fine, but we’re the wrong audience, buddy”?

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [February 22, 2022, 11:34pm UTC](https://community.auth0.com/t/best-practice-on-handling-aud-claims/78469/3 "2022-02-22T23:34:43Z")

</div>

Hi @martinbean,

Welcome to the Auth0 Community!

IIRC, this is how we handle it:

```auto
{
  statusCode: 401,
  error: 'Unauthorized',
  message: 'Bad audience: https://example-api'
}

```

---

<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 9, 2022, 11:35pm UTC](https://community.auth0.com/t/best-practice-on-handling-aud-claims/78469/4 "2022-03-09T23:35:04Z")

</div>

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