SfLoginLib 0.1.2

dotnet add package SfLoginLib --version 0.1.2
                    
NuGet\Install-Package SfLoginLib -Version 0.1.2
                    
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="SfLoginLib" Version="0.1.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SfLoginLib" Version="0.1.2" />
                    
Directory.Packages.props
<PackageReference Include="SfLoginLib" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SfLoginLib --version 0.1.2
                    
#r "nuget: SfLoginLib, 0.1.2"
                    
#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.
#:package SfLoginLib@0.1.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SfLoginLib&version=0.1.2
                    
Install as a Cake Addin
#tool nuget:?package=SfLoginLib&version=0.1.2
                    
Install as a Cake Tool

SfLoginLib

SfLoginLib is a small .NET library with one job: log in to Salesforce and return a session ID you can reuse for REST API calls.

What it does

  1. Reads the highest available Salesforce REST API version from /services/data/
  2. Performs a Salesforce SOAP login using:
    • username
    • password
    • security token (appended to password for login)
    • instance URL
  3. Verifies the returned session ID works against the REST API

If the highest REST version does not support SOAP login for the org yet, the library automatically falls back to the highest SOAP-supported version for login, while still using the highest REST version for subsequent REST API calls.

Important note about tokens

The Salesforce security token is used during login (appended to the password in the SOAP login request).

The session ID returned by this library is the value you normally use in:

Authorization: Bearer {sessionId}

Usage

using SfLoginLib;

var credentials = new SalesforceLoginCredentials(
    Username: "user@example.com",
    Password: "your-password",
    SecurityToken: "your-security-token",
    InstanceUri: new Uri("https://your-domain.lightning.force.com"));

using var loginClient = new SalesforceLoginClient();
SalesforceLoginResult result = await loginClient.LoginAsync(credentials);

Console.WriteLine(result.SessionId);
Console.WriteLine(result.ApiVersion);
Console.WriteLine(result.SoapLoginApiVersion);
Console.WriteLine(result.RestApiBaseUri);

Integration tests (safe setup)

The integration tests are in tests/SfLoginLib.IntegrationTests and do not store credentials in source control. They read from environment variables:

  • SFLOGIN_USERNAME
  • SFLOGIN_PASSWORD
  • SFLOGIN_SECURITY_TOKEN
  • SFLOGIN_INSTANCE_URL

Optional:

  • RUN_SF_INTEGRATION_TESTS=true (fail fast if credentials are missing instead of skipping)

Example:

export SFLOGIN_USERNAME="..."
export SFLOGIN_PASSWORD="..."
export SFLOGIN_SECURITY_TOKEN="..."
export SFLOGIN_INSTANCE_URL="https://your-domain.lightning.force.com"
dotnet test tests/SfLoginLib.IntegrationTests/SfLoginLib.IntegrationTests.csproj
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.

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
0.1.2 261 2/23/2026
0.1.1 254 2/23/2026
0.1.0 256 2/23/2026