@@ -14,6 +14,8 @@ Ensure that you have marked your account with iRacing for legacy authentication
1414
1515# Examples  
1616
17+ ## Using username/password credentials  
18+ 
1719``` python 
1820from  iracingdataapi.client import  irDataClient
1921
@@ -29,6 +31,31 @@ idc.stats_member_recent_races(cust_id=209179)
2931idc.result_lap_data(subsession_id = 43720351 , cust_id = 209179 )
3032``` 
3133
34+ ## Using Oauth2 access token  
35+ 
36+ When you have acquired an Oauth2 access token from iRacing, and have ensured that token is valid, you can
37+ use it like so in this client:
38+ 
39+ ``` python 
40+ from  iracingdataapi.client import  irDataClient
41+ 
42+ idc =  irDataClient(access_token = [YOUR  OAUTH2  TOKEN ])
43+ ``` 
44+ 
45+ The rest of the client will work exactly the same, except that when that token expires you will find the client
46+ raises an ` AccessTokenInvalid `  exception. For now, managing refreshing of tokens etc is outside the scope of
47+ this client, so build around that exception and reinitialise the client with a new token when necessary. For instance:
48+ 
49+ ``` python 
50+ try :
51+   lap_data =  idc.result_lap_data(subsession_id = 12345678 , cust_id = 987654 )
52+ except  AccessTokenInvalid:
53+   #  access token is invalid
54+   new_token =  do_something_in_your_code_to_refresh_token()
55+   idc =  irDataClient(access_token = [NEW  TOKEN ])
56+   lap_data =  idc.result_lap_data(subsession_id = 12345678 , cust_id = 987654 )
57+ ``` 
58+ 
3259All available methods of ` irDataClient `  are included in ` client.py ` .
3360
3461# Contributing  
0 commit comments