SDK Quick Start
This quick start guide introduces you to our dotnet SDK which makes it easy for C# developers to integrate with the WhenFresh API. It requires .NET Core to be already installed.
Create an async console application
Create a Console Application using the command line:
mkdir QuickStart
cd QuickStart
dotnet new console
Add the following entry to the PropertyGroup
section of the .csproj
:
<LangVersion>7.1</LangVersion>
The WhenFresh client is asynchronous, so make the Main
method async
:
static async Task Main(string[] args)
{
Console.WriteLine("Hello world!");
}
Ensure the new console application executes correctly.
Install the nuget package
Add the latest version of the WhenFresh.Api.Client
nuget package to the project using the command line:
dotnet add package WhenFresh.Api.Client --version 1.0.0
Authenticate
The WhenFresh API requires all access to be authenticated. During development, you will use a refresh token available from your account page.
Create an instance of the WhenFreshApiClient
and set the Credentials
option to use the refresh token:
var client = new WhenFreshApiClient(options =>
options.Credentials = new RefreshTokenCredentials("...your refresh token..."));
See the Authentication page for additional authentication options.