Data API Workflow
This workflow may be used by clients interested in making queries to /data on the behalf of an authenticated iRacing member. Previously, clients might have been constrained to using only the parts of the Data API which are not customer-specific. This workflow allows the client to access the full Data API without the need to handle user passwords.
Goals
- Use the full Data API without handling user passwords.
Prerequisites and Assumptions
- The client has been registered with an audience of
data-server. - The client can store access and refresh tokens securely.
Steps
- The client checks to see if it has an access token which has not expired. If
so, it may use the access token as a
Bearertoken in theAuthorizationheader while making requests to the Data API. It may continue to make requests until the access token expires or is otherwise invalidated. - The client checks to see if it has a refresh token which has not expired. If so, it may use the refresh token with the /token endpoint to obtain a new access token and a new refresh token. The client securely stores the new tokens. Return to Step 1.
- If the client has no valid access or refresh token, the client starts an
Authentication and Authorization flow by invoking
/authorize. The client should request the
scope
iracing.authto allow making requests as the authenticated user and specify the correctredirect_uriregistered to the client. - The user is asked to login and is told that the client has requested access
to iRacing services. It is assumed the user will approve. The browser is
redirected to the
redirect_uriwith acode. - The client receives the
codeat itsredirect_uri. It may then use /token to trade thecodefor an access token and a refresh token. The client securely stores the new tokens. Return to Step 1.