Auth0 Home Blog Docs

How do I add a grant type when creating a client (.net core 2.0)?



I am adding non-interactive clients of API access and looks like I need to add the client_credentials grant type. How do I add this via the ManagementApi using the .net core library.

I am using the following code to create the non interactive client then creating a grant to authorise it with an API, not sure where the grant types are specified, i.e. on the client or via adding a grant?

var client = GetClient(scopes);

                var clientCreateRequest = new ClientCreateRequest
                    Callbacks = new] {_auth0Settings.CallbackUrl},
                    IsFirstParty = false,
                    ClientMetaData = new {tenantId},
                    ApplicationType = ClientApplicationType.NonInteractive,
                    Name = name

                var nonInteractiveClient =  await client.Clients.CreateAsync(clientCreateRequest);

                var newClientGrantRequest = new ClientGrantCreateRequest
                    ClientId = nonInteractiveClient.ClientId,
                    Audience = _auth0Settings.ApiIdentifier,
                    Scope = new List<string> { }

                var newClientGrantResponse = await client.ClientGrants.CreateAsync(newClientGrantRequest);


Creating a non-interactive client manually sets default grant types, creating a non-interactive client via the API, one would expect the same defaults if created via the API?

Also if a non-interactive client is created via the API the grant types cannot be adjusted via the admin interface and not all the grant types are there (I don’t really want to select them there if I am creating them via the API but would be good to see them for consistency and sanity check)

Its seems form this post:

we need to set :

clientCreateRequest.TokenEndpointAuthMethod = TokenEndpointAuthMethod.ClientSecretPost;

I will try it and see

Where is all this stuff in the documentation? …cries with frustration…


As per my original post update:

when creating a client this setting is required to ensure that the client_credentials grant type is enabled

TokenEndpointAuthMethod = TokenEndpointAuthMethod.ClientSecretPost;