Howto associate application to api using .net SDK

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.

Hi @nra,

Welcome back!

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

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:

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

1 Like

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

Here is the direct API reference for more information:

1 Like