SfLoginLib 0.1.2
dotnet add package SfLoginLib --version 0.1.2
NuGet\Install-Package SfLoginLib -Version 0.1.2
<PackageReference Include="SfLoginLib" Version="0.1.2" />
<PackageVersion Include="SfLoginLib" Version="0.1.2" />
<PackageReference Include="SfLoginLib" />
paket add SfLoginLib --version 0.1.2
#r "nuget: SfLoginLib, 0.1.2"
#:package SfLoginLib@0.1.2
#addin nuget:?package=SfLoginLib&version=0.1.2
#tool nuget:?package=SfLoginLib&version=0.1.2
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
- Reads the highest available Salesforce REST API version from
/services/data/ - Performs a Salesforce SOAP login using:
- username
- password
- security token (appended to password for login)
- instance URL
- 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_USERNAMESFLOGIN_PASSWORDSFLOGIN_SECURITY_TOKENSFLOGIN_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 | Versions 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. |
-
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.