Skip to content

Commit 18be01e

Browse files
committed
Update "README" Files
1 parent ee76cb6 commit 18be01e

File tree

5 files changed

+158
-31
lines changed

5 files changed

+158
-31
lines changed

README.md

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,25 @@
66

77
This library allows access via .NET to the iRacing "Data API". These APIs allow a properly authenticated user a supported method of accessing data from the service.
88

9-
[![Nuget](https://img.shields.io/nuget/dt/Aydsko.iRacingData?color=004880&label=NuGet&logo=NuGet)](https://www.nuget.org/packages/Aydsko.iRacingData)
9+
## Authentication Types
1010

11-
## ⚠ Multi-Factor Authentication Requirement
11+
### Legacy Authentication (Username / Password)
1212

13-
iRacing now require multi-factor authentication (MFA) for all users by default. This will affect the ability to use the iRacing Data API by logging in with a username or password.
13+
iRacing now requires multi-factor authentication (MFA) for all users by default. This will affect the ability to use the iRacing Data API by logging in with a username or password.
1414

15-
In the immediate future, use of the Data API will be supported by enabling "Legacy Authentication" in your iRacing account settings. iRacing will advise next steps for the authentication of applications for the Data API later on.
15+
Use of the Data API will be supported by enabling "Legacy Authentication" in your iRacing account settings. iRacing will advise next steps for the authentication of applications for the Data API later on.
1616

17-
To continue to use this library you **must** [enable "Legacy Authentication" in your iRacing account settings](https://support.iracing.com/support/solutions/articles/31000173894-enabling-or-disabling-legacy-read-only-authentication) before attempting to authenticate. Please **do not** enable this setting unless you require it, as it may reduce the security on your iRacing account.
17+
To use username & password authentication with this library you **must** [enable "Legacy Authentication" in your iRacing account settings](https://support.iracing.com/support/solutions/articles/31000173894-enabling-or-disabling-legacy-read-only-authentication) before attempting to authenticate. Please **do not** enable this setting unless you require it, as it may reduce the security on your iRacing account.
18+
19+
**⚠ Note:** Legacy authentication will be removed 9 Dec 2025 and one of the OAuth-based authentication methods required. See: https://forums.iracing.com/discussion/84226/legacy-authentication-removal-dec-9-2025
20+
21+
### iRacing OAuth "Password Limited Grant" Authentication
22+
23+
The "Password Limited Grant" is authentication intended for scripts or back-end processes that do not need to access the details of specific users.
24+
25+
Full information is available from the [iRacing.com Auth Service "Password Limited Grant" page](https://oauth.iracing.com/oauth2/book/token_endpoint.html#password-limited-grant).
26+
27+
To use this authentication method you need to contact iRacing who will allocate a "Client ID" and "Client Secret".
1828

1929
## Getting Started
2030

@@ -30,11 +40,29 @@ dotnet add package Aydsko.iRacingData
3040

3141
Register the iRacing Data API client classes with the service provider.
3242

43+
Using legacy username/password authentication:
44+
3345
```csharp
3446
services.AddIRacingDataApi(options =>
3547
{
36-
options.UserAgentProductName = "MyApplicationName";
37-
options.UserAgentProductVersion = new Version(1, 0);
48+
options.UseProductUserAgent("MyApplicationName", new Version(1, 0));
49+
50+
// Supply your iRacing username and password.
51+
options.UseUsernamePasswordAuthentication(iRacingUsername, iRacingPassword);
52+
});
53+
```
54+
55+
OR
56+
57+
Using iRacing OAuth "Password Limited Grant" authentication:
58+
59+
```csharp
60+
services.AddIRacingDataApi(options =>
61+
{
62+
options.UseProductUserAgent("MyApplicationName", new Version(1, 0));
63+
64+
// Supply your iRacing username, password, client id, and client secret.
65+
options.UsePasswordLimitedOAuth(iRacingUsername, iRacingPassword, iRacingClientId, iRacingClientSecret);
3866
});
3967
```
4068

@@ -46,9 +74,6 @@ Use the `IDataClient` from the service provider to authenticate and request data
4674
// Retrieve an instance from the service provider.
4775
var dataClient = serviceProvider.GetRequiredService<IDataClient>();
4876

49-
// Supply your iRacing username and password.
50-
dataClient.UseUsernameAndPassword(iRacingUsername, iRacingPassword);
51-
5277
// Retrieve information about our own account.
5378
var infoResponse = await dataClient.GetMyInfoAsync(cancellationToken);
5479

@@ -79,8 +104,7 @@ Register the iRacing Data API caching client classes with the service provider.
79104
```csharp
80105
services.AddIRacingDataApiWithCaching(options =>
81106
{
82-
options.UserAgentProductName = "MyApplicationName";
83-
options.UserAgentProductVersion = new Version(1, 0);
107+
// [... normal configuration for your chosen authentication type here]
84108
});
85109
```
86110

src/Aydsko.iRacingData.UnitTests/OAuth/OAuthPasswordLimitedAuthenticatingHttpClientTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public async Task GivenAnUnauthenticatedClient_WhenARequestIsMade_ThenTheTokenIs
2929
fakeHandler.AddJsonResponse(new("https://oauth.iracing.com/oauth2/token"), HttpStatusCode.OK, ValidTokenResponseJson);
3030
fakeHandler.AddJsonResponse(new("https://example.com/test-request"), HttpStatusCode.OK, "{\"value\":true}");
3131

32-
var options = new iRacingDataClientOptions().UsePasswordLimitedAuthentication("test.user@example.com",
32+
var options = new iRacingDataClientOptions().UsePasswordLimitedOAuth("test.user@example.com",
3333
"SuperSecretPassword",
3434
"UnitTestApp",
3535
"Secret-Client-Password");
@@ -98,7 +98,7 @@ public async Task GivenAnAuthenticatedClient_WhenTimePasses_ThenTheRefreshTokenI
9898
});
9999
fakeHandler.AddJsonResponse(new("https://example.com/test-request"), HttpStatusCode.OK, "{\"value\":true}");
100100

101-
var options = new iRacingDataClientOptions().UsePasswordLimitedAuthentication("test.user@example.com",
101+
var options = new iRacingDataClientOptions().UsePasswordLimitedOAuth("test.user@example.com",
102102
"SuperSecretPassword",
103103
"UnitTestApp",
104104
"Secret-Client-Password");

src/Aydsko.iRacingData/Package README.md

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,25 @@
44

55
This library allows access via .NET to the iRacing "Data API". These APIs allow a properly authenticated user a supported method of accessing data from the service.
66

7-
## ⚠ Multi-Factor Authentication Requirement
7+
## Authentication Types
88

9-
iRacing now require multi-factor authentication (MFA) for all users by default. This will affect the ability to use the iRacing Data API by logging in with a username or password.
9+
### Legacy Authentication (Username / Password)
1010

11-
In the immediate future, use of the Data API will be supported by enabling "Legacy Authentication" in your iRacing account settings. iRacing will advise next steps for the authentication of applications for the Data API later on.
11+
iRacing now requires multi-factor authentication (MFA) for all users by default. This will affect the ability to use the iRacing Data API by logging in with a username or password.
1212

13-
To continue to use this library you **must** [enable "Legacy Authentication" in your iRacing account settings](https://support.iracing.com/support/solutions/articles/31000173894-enabling-or-disabling-legacy-read-only-authentication) before attempting to authenticate. Please **do not** enable this setting unless you require it, as it may reduce the security on your iRacing account.
13+
Use of the Data API will be supported by enabling "Legacy Authentication" in your iRacing account settings. iRacing will advise next steps for the authentication of applications for the Data API later on.
14+
15+
To use username & password authentication with this library you **must** [enable "Legacy Authentication" in your iRacing account settings](https://support.iracing.com/support/solutions/articles/31000173894-enabling-or-disabling-legacy-read-only-authentication) before attempting to authenticate. Please **do not** enable this setting unless you require it, as it may reduce the security on your iRacing account.
16+
17+
**⚠ Note:** Legacy authentication will be removed 9 Dec 2025 and one of the OAuth-based authentication methods required. See: https://forums.iracing.com/discussion/84226/legacy-authentication-removal-dec-9-2025
18+
19+
### iRacing OAuth "Password Limited Grant" Authentication
20+
21+
The "Password Limited Grant" is authentication intended for scripts or back-end processes that do not need to access the details of specific users.
22+
23+
Full information is available from the [iRacing.com Auth Service "Password Limited Grant" page](https://oauth.iracing.com/oauth2/book/token_endpoint.html#password-limited-grant).
24+
25+
To use this authentication method you need to contact iRacing who will allocate a "Client ID" and "Client Secret".
1426

1527
## Getting Started
1628

@@ -26,11 +38,29 @@ dotnet add package Aydsko.iRacingData
2638

2739
Register the iRacing Data API client classes with the service provider.
2840

41+
Using legacy username/password authentication:
42+
43+
```csharp
44+
services.AddIRacingDataApi(options =>
45+
{
46+
options.UseProductUserAgent("MyApplicationName", new Version(1, 0));
47+
48+
// Supply your iRacing username and password.
49+
options.UseUsernamePasswordAuthentication(iRacingUsername, iRacingPassword);
50+
});
51+
```
52+
53+
OR
54+
55+
Using iRacing OAuth "Password Limited Grant" authentication:
56+
2957
```csharp
3058
services.AddIRacingDataApi(options =>
3159
{
32-
options.UserAgentProductName = "MyApplicationName";
33-
options.UserAgentProductVersion = new Version(1, 0);
60+
options.UseProductUserAgent("MyApplicationName", new Version(1, 0));
61+
62+
// Supply your iRacing username, password, client id, and client secret.
63+
options.UsePasswordLimitedOAuth(iRacingUsername, iRacingPassword, iRacingClientId, iRacingClientSecret);
3464
});
3565
```
3666

@@ -42,9 +72,6 @@ Use the `IDataClient` from the service provider to authenticate and request data
4272
// Retrieve an instance from the service provider.
4373
var dataClient = serviceProvider.GetRequiredService<IDataClient>();
4474

45-
// Supply your iRacing username and password.
46-
dataClient.UseUsernameAndPassword(iRacingUsername, iRacingPassword);
47-
4875
// Retrieve information about our own account.
4976
var infoResponse = await dataClient.GetMyInfoAsync(cancellationToken);
5077

@@ -75,8 +102,7 @@ Register the iRacing Data API caching client classes with the service provider.
75102
```csharp
76103
services.AddIRacingDataApiWithCaching(options =>
77104
{
78-
options.UserAgentProductName = "MyApplicationName";
79-
options.UserAgentProductVersion = new Version(1, 0);
105+
// [... normal configuration for your chosen authentication type here]
80106
});
81107
```
82108

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
BREAKING CHANGES:
2-
- All references to iRacing Clubs have been removed. iRacing no longer supports Clubs (see: https://forums.iracing.com/discussion/77912/disbanding-of-clubs-and-raising-of-flags)
32
- "IDataClient.GetMemberChartData" method was removed. Use "IDataClient.GetMemberChartDataAsync" instead.
43
- The "TrackScreenshotService" class has been removed. Use "IDataClient.GetTrackAssetScreenshotUris\" or "IDataClient.GetTrackAssetScreenshotUrisAsync" instead.
54

65
FIXES:
7-
- Update League, League Season, and League Session calls. Including weather for League Sessions. (Issue #237)
8-
- Improve League tag handling.
9-
- Implement the "/data/lookup/flairs" endpoint to retrieve available flair, or driver flags. (Issue #238)
10-
- Implement Track Package Id based paths for logo files. (Issue #240)
6+
- Various properties updated to match results (DriverInfo, LicenseInfo, MemberInfo)
7+
8+
NEW FEATURE: iRacing OAuth "Password Limited Grant" Authentication
9+
- Allows authentication using "Client ID" and "Client Secret" issued by iRacing.
10+
- This authentication will be required after 9 Dec 2025 (see https://forums.iracing.com/discussion/84226/legacy-authentication-removal-dec-9-2025).
11+
- See https://oauth.iracing.com/oauth2/book/token_endpoint.html#password-limited-grant for more information.

src/Aydsko.iRacingData/ServicesExtensions.cs

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,45 @@ private static string CreateUserAgentValue(iRacingDataClientOptions options)
181181
return userAgentValue;
182182
}
183183

184+
/// <summary>Configure the options to use legacy iRacing username/password authentication.</summary>
185+
/// <param name="options">The options object to configure.</param>
186+
/// <param name="userName">iRacing username</param>
187+
/// <param name="password">iRacing password</param>
188+
/// <param name="passwordIsEncoded">Indicates that the <paramref name="password"/> value is already encoded for supply to the iRacing Authentication API.</param>
189+
/// <returns>The options object to allow call chaining.</returns>
190+
public static iRacingDataClientOptions UseUsernamePasswordAuthentication(this iRacingDataClientOptions options,
191+
string userName,
192+
string password,
193+
bool passwordIsEncoded = false)
194+
{
195+
#if NET6_0_OR_GREATER
196+
ArgumentNullException.ThrowIfNull(options);
197+
ArgumentException.ThrowIfNullOrWhiteSpace(userName);
198+
ArgumentException.ThrowIfNullOrWhiteSpace(password);
199+
#else
200+
if (options is null)
201+
{
202+
throw new ArgumentNullException(nameof(options));
203+
}
204+
205+
if (string.IsNullOrWhiteSpace(userName))
206+
{
207+
throw new ArgumentNullException(nameof(userName));
208+
}
209+
210+
if (string.IsNullOrWhiteSpace(password))
211+
{
212+
throw new ArgumentNullException(nameof(password));
213+
}
214+
#endif
215+
216+
options.Username = userName;
217+
options.Password = password;
218+
options.PasswordIsEncoded = passwordIsEncoded;
219+
220+
return options;
221+
}
222+
184223
/// <summary>Configure the options to use "Password Limited" iRacing authentication.</summary>
185224
/// <param name="options">The options object to configure.</param>
186225
/// <param name="userName">iRacing username</param>
@@ -190,7 +229,7 @@ private static string CreateUserAgentValue(iRacingDataClientOptions options)
190229
/// <param name="passwordIsEncoded">Indicates that the <paramref name="password"/> value is already encoded for supply to the iRacing Authentication API.</param>
191230
/// <param name="clientSecretIsEncoded">Indicates that the <paramref name="clientSecret"/> value is already encoded for supply to the iRacing Authentication API.</param>
192231
/// <returns>The options object to allow call chaining.</returns>
193-
public static iRacingDataClientOptions UsePasswordLimitedAuthentication(this iRacingDataClientOptions options,
232+
public static iRacingDataClientOptions UsePasswordLimitedOAuth(this iRacingDataClientOptions options,
194233
string userName,
195234
string password,
196235
string clientId,
@@ -240,4 +279,41 @@ public static iRacingDataClientOptions UsePasswordLimitedAuthentication(this iRa
240279

241280
return options;
242281
}
282+
283+
/// <summary>Configure the user agent details to use in requests.</summary>
284+
/// <param name="options">The options object to configure.</param>
285+
/// <param name="productName">Name of the client.</param>
286+
/// <param name="productVersion">Version of the client.</param>
287+
/// <returns>The options object to allow call chaining.</returns>
288+
public static iRacingDataClientOptions UseProductUserAgent(this iRacingDataClientOptions options,
289+
string productName,
290+
Version productVersion)
291+
{
292+
#if NET6_0_OR_GREATER
293+
ArgumentNullException.ThrowIfNull(options);
294+
ArgumentException.ThrowIfNullOrWhiteSpace(productName);
295+
ArgumentNullException.ThrowIfNull(productVersion);
296+
#else
297+
if (options is null)
298+
{
299+
throw new ArgumentNullException(nameof(options));
300+
}
301+
302+
if (string.IsNullOrWhiteSpace(productName))
303+
{
304+
throw new ArgumentNullException(nameof(productName));
305+
}
306+
307+
if (productVersion is null)
308+
{
309+
throw new ArgumentNullException(nameof(productVersion));
310+
}
311+
#endif
312+
313+
options.UserAgentProductName = productName;
314+
options.UserAgentProductVersion = productVersion;
315+
316+
return options;
317+
}
318+
243319
}

0 commit comments

Comments
 (0)