Skip to content

Commit 35846a5

Browse files
committed
docs: addtional usage examples
1 parent 94ef134 commit 35846a5

7 files changed

Lines changed: 500 additions & 138 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Changelog
22

3-
### 2026-08-01 v6.0.0
3+
### 2026-10-01 v6.0.0
44

55
* feat: add net10.0 and .net481 support
66
* Remove EOL frameworks

‎docfx.json‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
]
1212
}
1313
],
14+
"properties": {
15+
"TargetFramework": "netstandard2.0"
16+
},
1417
"dest": "docs/api"
1518
}
1619
],

‎docs/auth.md‎

Lines changed: 41 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -9,44 +9,6 @@ All `AuthenticationClient` flow methods throw a [`ForceAuthException`](xref:NetC
99

1010
---
1111

12-
## Username-Password Flow
13-
14-
The simplest flow for server-to-server integrations where the application can hold the user's credentials directly.
15-
16-
One-step, via the [`ForceClient(AuthInfo)`](xref:NetCoreForce.Client.ForceClient.%23ctor(NetCoreForce.Client.Models.AuthInfo)) constructor:
17-
```csharp
18-
AuthInfo authInfo = new AuthInfo
19-
{
20-
ClientId = "your-client-id",
21-
ClientSecret = "your-client-secret",
22-
Username = "your-username",
23-
Password = "your-password",
24-
TokenRequestEndpoint = "https://login.salesforce.com/services/oauth2/token"
25-
};
26-
27-
ForceClient client = new ForceClient(authInfo);
28-
```
29-
30-
Or without building an [`AuthInfo`](xref:NetCoreForce.Client.Models.AuthInfo) object:
31-
```csharp
32-
ForceClient client = new ForceClient("your-client-id", "your-client-secret", "your-username", "your-password", "https://login.salesforce.com/services/oauth2/token");
33-
```
34-
35-
If you need the raw token response first (e.g. to inspect or persist it), use [`AuthenticationClient.UsernamePasswordAsync`](xref:NetCoreForce.Client.AuthenticationClient.UsernamePasswordAsync(System.String,System.String,System.String,System.String,System.String)) and build the client from the result:
36-
```csharp
37-
AuthenticationClient auth = new AuthenticationClient();
38-
await auth.UsernamePasswordAsync("your-client-id", "your-client-secret", "your-username", "your-password", "https://login.salesforce.com/services/oauth2/token");
39-
40-
ForceClient client = new ForceClient(auth.AccessInfo.InstanceUrl, auth.ApiVersion, auth.AccessInfo.AccessToken);
41-
```
42-
43-
A synchronous [`UsernamePassword`](xref:NetCoreForce.Client.AuthenticationClient.UsernamePassword(System.String,System.String,System.String,System.String,System.String)) overload is also available if you can't use `async`/`await`.
44-
45-
> [!NOTE]
46-
> This flow does not return a refresh token — see [Refreshing an Access Token](#refreshing-an-access-token) below.
47-
48-
---
49-
5012
## Client Credentials Flow
5113

5214
Server-to-server authentication with no end user involved, using only the connected app's Consumer Key/Secret.
@@ -171,3 +133,44 @@ catch (ForceAuthException ex)
171133
Console.WriteLine($"{ex.ErrorCode}: {ex.Message}");
172134
}
173135
```
136+
137+
---
138+
139+
## Username-Password Flow
140+
141+
> [!WARNING]
142+
> The OAuth Username-Password flow is deprecated and Salesforce recommends against using it. It is blocked by default in orgs created in Summer '23 or later, and admins can disable it in any org (Setup > OAuth and OpenID Connect Settings > *Allow OAuth Username-Password Flows*), so it may not be available in your org. For new integrations, use the [Client Credentials Flow](#client-credentials-flow) for server-to-server access, or the [Web Server Flow](#web-server-authorization-code-flow) when a user logs in.
143+
144+
The application holds the user's credentials directly and exchanges them for an access token.
145+
146+
One-step, via the [`ForceClient(AuthInfo)`](xref:NetCoreForce.Client.ForceClient.%23ctor(NetCoreForce.Client.Models.AuthInfo)) constructor:
147+
```csharp
148+
AuthInfo authInfo = new AuthInfo
149+
{
150+
ClientId = "your-client-id",
151+
ClientSecret = "your-client-secret",
152+
Username = "your-username",
153+
Password = "your-password",
154+
TokenRequestEndpoint = "https://login.salesforce.com/services/oauth2/token"
155+
};
156+
157+
ForceClient client = new ForceClient(authInfo);
158+
```
159+
160+
Or without building an [`AuthInfo`](xref:NetCoreForce.Client.Models.AuthInfo) object:
161+
```csharp
162+
ForceClient client = new ForceClient("your-client-id", "your-client-secret", "your-username", "your-password", "https://login.salesforce.com/services/oauth2/token");
163+
```
164+
165+
If you need the raw token response first (e.g. to inspect or persist it), use [`AuthenticationClient.UsernamePasswordAsync`](xref:NetCoreForce.Client.AuthenticationClient.UsernamePasswordAsync(System.String,System.String,System.String,System.String,System.String)) and build the client from the result:
166+
```csharp
167+
AuthenticationClient auth = new AuthenticationClient();
168+
await auth.UsernamePasswordAsync("your-client-id", "your-client-secret", "your-username", "your-password", "https://login.salesforce.com/services/oauth2/token");
169+
170+
ForceClient client = new ForceClient(auth.AccessInfo.InstanceUrl, auth.ApiVersion, auth.AccessInfo.AccessToken);
171+
```
172+
173+
A synchronous [`UsernamePassword`](xref:NetCoreForce.Client.AuthenticationClient.UsernamePassword(System.String,System.String,System.String,System.String,System.String)) overload is also available if you can't use `async`/`await`.
174+
175+
> [!NOTE]
176+
> This flow does not return a refresh token — see [Refreshing an Access Token](#refreshing-an-access-token).

0 commit comments

Comments
 (0)