# Audience required for API Access and ASP.NET Core Samples not working

**URL:** <https://community.auth0.com/t/audience-required-for-api-access-and-asp-net-core-samples-not-working/6768>\
**Category:** Get Help\
**Tags:** aspnet-core\
**Created:** [May 26, 2017, 11:15pm UTC](https://community.auth0.com/t/audience-required-for-api-access-and-asp-net-core-samples-not-working/6768 "2017-05-26T23:15:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mail1](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/mail1/32/7189_2.png) [@mail1](https://community.auth0.com/u/mail1)\
**Post date:** [May 26, 2017, 11:15pm UTC](https://community.auth0.com/t/audience-required-for-api-access-and-asp-net-core-samples-not-working/6768/1 "2017-05-26T23:15:00Z")

</div>

I noticed that to gain API access you have to set the audience with the first authorization request. Even if you’re using the Authorization Code Flow. As `OpenIdConnectOptions` doesn’t suppor that - the [ASP.NET](http://ASP.NET) Core samples for storing the tokens aren’t working properly.

Is there a way to configure the Client in Auth0 to NOT require the Audience to grant an access token when trading the authorization code?

---

<div class="post-metadata">

**Author:** ![jmangelo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jmangelo/32/7923_2.png) [@jmangelo](https://community.auth0.com/u/jmangelo)\
**Post date:** [May 26, 2017, 11:45pm UTC](https://community.auth0.com/t/audience-required-for-api-access-and-asp-net-core-samples-not-working/6768/2 "2017-05-26T23:45:30Z")

</div>

You should be able to add additional parameters using an approach similar to the following:

```
app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions()
{
    // Other configuration and standard parameters
    // ...
    Events = new OpenIdConnectEvents
    {
        OnRedirectToIdentityProvider = context =>
        {
            context.ProtocolMessage.SetParameter("audience", "https://api.example.com/");

            return Task.FromResult(0);
        }
    }
});

```

---

<div class="post-metadata">

**Author:** ![mail1](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/mail1/32/7189_2.png) [@mail1](https://community.auth0.com/u/mail1)\
**Post date:** [May 27, 2017, 12:08am UTC](https://community.auth0.com/t/audience-required-for-api-access-and-asp-net-core-samples-not-working/6768/3 "2017-05-27T00:08:05Z")

</div>

Yep. But why is that required? Is that specified in any of the RFCs? Also, why is there no setting on the Client to disable it?

---

<div class="post-metadata">

**Author:** ![jmangelo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jmangelo/32/7923_2.png) [@jmangelo](https://community.auth0.com/u/jmangelo)\
**Post date:** [May 27, 2017, 12:59am UTC](https://community.auth0.com/t/audience-required-for-api-access-and-asp-net-core-samples-not-working/6768/4 "2017-05-27T00:59:38Z")

</div>

It’s not part of the OAuth2 RFC’s or OIDC, it’s a provider specific parameter (which in the OAuth2 world is nothing that uncommon). It’s needed as a way to know to which API the access token is meant to be issued. You can configure a default audience in your account settings which would mean you would not have to actually pass the parameter in the request as it would be implied from the global setting.

---

<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 2, 2018, 5:54am UTC](https://community.auth0.com/t/audience-required-for-api-access-and-asp-net-core-samples-not-working/6768/5 "2018-03-02T05:54:09Z")

</div>


