Skip to content

TmcClient class

kimmoal edited this page Nov 22, 2017 · 5 revisions

TmcClient

TmcClient is the main class through which to communicate with the TMC server.

For now it makes the authentication request to the server to obtain the access token for further communication, and can get the authenticated user's info.

The plan is to use this class for all communication with TMC server, such as getting the new exercises and sending things to the server.

Authentication

The way oauth2 authentication works in TestMyCode terms, is that a POST request to the server is sent with the following parameters:

  • client_id and client_secret: Used to authorize the client application. Fetched from the server at first startup, and static for the application at this time. Cached in application QSettings.
  • username and password: valid TestMyCode credentials to authenticate the user
  • grant_type as password: to indicate we are using the oauth2 password authentication flow.

If the login information is correct, the server responds with a JSON that has our access token, which is then used in further communication with the server.