Webion.ClickUp.Api.V2 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Webion.ClickUp.Api.V2 --version 1.0.0                
NuGet\Install-Package Webion.ClickUp.Api.V2 -Version 1.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Webion.ClickUp.Api.V2" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Webion.ClickUp.Api.V2 --version 1.0.0                
#r "nuget: Webion.ClickUp.Api.V2, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Webion.ClickUp.Api.V2 as a Cake Addin
#addin nuget:?package=Webion.ClickUp.Api.V2&version=1.0.0

// Install Webion.ClickUp.Api.V2 as a Cake Tool
#tool nuget:?package=Webion.ClickUp.Api.V2&version=1.0.0                

Overview

This package adds support for the ClickUp v2 api.

Usage

The recommended approach is to register the api inside a service collection, and then inject it inside your services.

Example

builder.Services
    .AddClickUpApi()
    .ConfigureHttpClient(x =>
    {
        x.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(
            builder.Configuration["ClickUp:ApiKey"]!
        );
    });
public sealed class MyService
{
    private readonly IClickUpApi _clickUpApi;
    
    public MyService(IClickUpApi clickUpApi)
    {
        _clickUpApi = clickUpApi;
    }
    
    public async Task DoSomething()
    {
        var getAllTeamsResponse = await _clickUpApi.Teams.GetAllAsync();
    }
}

Authentication

You can either add an api key like in the example above, or leverage the http delegating handlers to send an AccessToken.

Access token example

public sealed class ClickUpApiAuthHandler : DelegatingHandler
{
    private readonly IHttpContextAccessor _httpContextAccessor;

    public ClickUpApiAuthHandler(IHttpContextAccessor httpContextAccessor)
    {
        _httpContextAccessor = httpContextAccessor;
    }

    protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
    {
        // Example of retrieving the access token from the user's claims
        var user = _httpContextAccessor.HttpContext?.User;
        var token = user?.FindFirstValue("clickup_access_token");
        if (token is not null)
        {
            request.Headers.Authorization = new AuthenticationHeaderValue(token);
        }
        
        return base.SendAsync(request, cancellationToken);
    }
}

// Registering the handler
builder.Services.AddTransient<ClickUpApiAuthHandler>();
builder.Services
    .AddClickUpApi()
    .AddHttpMessageHandler<ClickUpApiAuthHandler>();
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 126 10/20/2024
1.0.0 99 10/16/2024