How to generate a FusionAuth API key using .Net core client library

123 Views Asked by At

I am kind of new to FusionAuth. I need to generate a new API key for a newly created tenant. I was able to create new tenant using same client library but having a hard time generating API key. Following snippet shows the code I wrote for the task in hand.

var apiKeyCreateResponse = await authClient.CreateAPIKeyAsync(null, new APIKeyRequest
{
    apiKey = new APIKey
    {
        tenantId = tenant.id,
        permissions = new APIKeyPermissions
        {
            endpoints = new Dictionary<string, List<string>>
            {
                {"/api/tenant", new List<string>{ "GET" }}
            }
        }
    }
});

I am getting 404 with this code with an exception message Unexpected character encountered while parsing value: <. Path '', line 0, position 0.

The new API key should be restricted to access GET /api/tenant endpoint only. Can anyone please provide some direction on this? I am not quite sure if I am constructing the endpoints object correctly. Any help on this will be very much appreciated. Thanks.

FusionAuth Client Version I am using: 1.26.0

0

There are 0 best solutions below