# Howto associate application to api using .net SDK

**URL:** <https://community.auth0.com/t/howto-associate-application-to-api-using-net-sdk/70857>\
**Category:** Get Help\
**Created:** [October 6, 2021, 7:21am UTC](https://community.auth0.com/t/howto-associate-application-to-api-using-net-sdk/70857 "2021-10-06T07:21:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nra](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nra/32/22743_2.png) [@nra](https://community.auth0.com/u/nra)\
**Post date:** [October 6, 2021, 7:21am UTC](https://community.auth0.com/t/howto-associate-application-to-api-using-net-sdk/70857/1 "2021-10-06T07:21:29Z")

</div>

Regarding . Net SDK 7.10.0  
Creating a new client/application works like a dream, but then I need to associate that application to an existing API.  
Optionally a REST call would be helpful.  
Please help me out.

---

<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:** [October 6, 2021, 8:20pm UTC](https://community.auth0.com/t/howto-associate-application-to-api-using-net-sdk/70857/3 "2021-10-06T20:20:09Z")

</div>

Hi @nra,

Welcome back!

Can you please elaborate on your question? Providing an example could be helpful!

---

<div class="post-metadata">

**Author:** ![nra](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nra/32/22743_2.png) [@nra](https://community.auth0.com/u/nra)\
**Post date:** [October 7, 2021, 7:24am UTC](https://community.auth0.com/t/howto-associate-application-to-api-using-net-sdk/70857/4 "2021-10-07T07:24:22Z")

</div>

Hi Dan.  
Thanks for helping.  
So from the Management Portal you can create Applications and APIs and within each Application you can authorize an API to the that specific Application.  
My situation is that I need to create Applications programmatically using some .Net code and this is where the .Net SDK kicks in.  
I can easily create the Application like this:

```auto
ManagementApiClient managementClient = new ManagementApiClient(token, new Uri("https://mydomain.eu.auth0.com/api/v2"));
ClientCreateRequest clientReq = new ClientCreateRequest
{
      ApplicationType = ClientApplicationType.NonInteractive,
      GrantTypes = new []{ "client_credentials" },
      Name = name,
      JwtConfiguration = new JwtConfiguration { IsSecretEncoded = false, LifetimeInSeconds = 36000, SigningAlgorithm = "RS256"},
      TokenEndpointAuthMethod = TokenEndpointAuthMethod.ClientSecretPost,  
      ClientMetaData = new {data = id}
};
await managementClient.Clients.CreateAsync(clientReq);

```

Next step is to perform the authorization of my existing API to this new Application in .Net, similar to what you can do from the Application page within the APIs tab.  
I hope this clarifies the question.  
Thanks

---

<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:** [October 7, 2021, 5:55pm UTC](https://community.auth0.com/t/howto-associate-application-to-api-using-net-sdk/70857/5 "2021-10-07T17:55:50Z")

</div>

Yes, that is clarifying! Thank you.

You are looking to create a _client grant_. Here is the .NET SDK method for it:

[https://auth0.github.io/auth0.net/api/Auth0.ManagementApi.Models.ClientGrantCreateRequest.html](https://auth0.github.io/auth0.net/api/Auth0.ManagementApi.Models.ClientGrantCreateRequest.html)

Here is the direct API reference for more information:

> **[Auth0 Management API v2](https://auth0.com/docs/api/management/v2#!/Client_Grants/get_client_grantshtt)**

---

<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:** [October 22, 2021, 5:56pm UTC](https://community.auth0.com/t/howto-associate-application-to-api-using-net-sdk/70857/6 "2021-10-22T17:56:01Z")

</div>

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