AuthenticationClient¶
Namespace: IntegrationTests.ApiClient
Inheritance Object → AuthenticationClient
Properties¶
BaseUrl¶
Property Value¶
ReadResponseAsString¶
Property Value¶
Constructors¶
AuthenticationClient(String, HttpClient)¶
Parameters¶
baseUrl String
httpClient HttpClient
Methods¶
LoginAsync(Login)¶
Authenticates a user and returns a JWT token for API access.
Parameters¶
input Login
The login credentials containing username and password.
Returns¶
Authentication successful. Returns JWT access token and refresh token.
Exceptions¶
ApiException
A server side error occurred.
Remarks:
This endpoint validates user credentials and returns a JWT access token and refresh token.
The returned tokens should be used for authenticating subsequent API requests.
Example request:
json <br>{ <br>"userName": "admin", <br>"password": "your-password" <br>} <br>
Example response:
json <br>{ <br>"accessToken": "CakeIsNotALie.", <br>"refreshToken": "refresh-token-here", <br>"expiresIn": 3600 <br>} <br>
LoginAsync(Login, CancellationToken)¶
Authenticates a user and returns a JWT token for API access.
Parameters¶
input Login
The login credentials containing username and password.
cancellationToken CancellationToken
A cancellation token that can be used by other objects or threads to receive notice of cancellation.
Returns¶
Authentication successful. Returns JWT access token and refresh token.
Exceptions¶
ApiException
A server side error occurred.
Remarks:
This endpoint validates user credentials and returns a JWT access token and refresh token.
The returned tokens should be used for authenticating subsequent API requests.
Example request:
json <br>{ <br>"userName": "admin", <br>"password": "your-password" <br>} <br>
Example response:
json <br>{ <br>"accessToken": "CakeIsNotALie.", <br>"refreshToken": "refresh-token-here", <br>"expiresIn": 3600 <br>} <br>
ReadObjectResponseAsync<T>(HttpResponseMessage, IReadOnlyDictionary<String, IEnumerable<String>>, CancellationToken)¶
protected Task<ObjectResponseResult<T>> ReadObjectResponseAsync<T>(HttpResponseMessage response, IReadOnlyDictionary<String, IEnumerable<String>> headers, CancellationToken cancellationToken)
Type Parameters¶
T
Parameters¶
response HttpResponseMessage
headers IReadOnlyDictionary<String, IEnumerable<String>>
cancellationToken CancellationToken
Returns¶
Task<ObjectResponseResult<T>>
RefreshAsync(JwtToken)¶
Refreshes an expired JWT access token using a valid refresh token.
Parameters¶
token JwtToken
The JWT token object containing both the expired access token and valid refresh token.
Returns¶
Token refresh successful. Returns new access and refresh tokens.
Exceptions¶
ApiException
A server side error occurred.
Remarks:
This endpoint allows clients to obtain a new access token without requiring
the user to log in again. The refresh token must be valid and not expired.
Use this endpoint when your access token expires to maintain continuous
authentication without user intervention.
Example request:
json <br>{ <br>"accessToken": "expired-access-token", <br>"refreshToken": "valid-refresh-token" <br>} <br>
Example response:
json <br>{ <br>"accessToken": "new-jwt-access-token", <br>"refreshToken": "new-refresh-token", <br>"expiresIn": 3600 <br>} <br>
RefreshAsync(JwtToken, CancellationToken)¶
Refreshes an expired JWT access token using a valid refresh token.
Parameters¶
token JwtToken
The JWT token object containing both the expired access token and valid refresh token.
cancellationToken CancellationToken
A cancellation token that can be used by other objects or threads to receive notice of cancellation.
Returns¶
Token refresh successful. Returns new access and refresh tokens.
Exceptions¶
ApiException
A server side error occurred.
Remarks:
This endpoint allows clients to obtain a new access token without requiring
the user to log in again. The refresh token must be valid and not expired.
Use this endpoint when your access token expires to maintain continuous
authentication without user intervention.
Example request:
json <br>{ <br>"accessToken": "expired-access-token", <br>"refreshToken": "valid-refresh-token" <br>} <br>
Example response:
json <br>{ <br>"accessToken": "new-jwt-access-token", <br>"refreshToken": "new-refresh-token", <br>"expiresIn": 3600 <br>} <br>
RegisterAsync(Register)¶
Registers a new user in the system. Admin access required.
Parameters¶
input Register
The registration data containing username and password for the new user.
Returns¶
User registered successfully.
Exceptions¶
ApiException
A server side error occurred.
Remarks:
This endpoint allows administrators to create new user accounts in the system.
Only users with the "Admin" role can access this endpoint.
Authorization Required: Bearer token with Admin role
Example request:
json <br>{ <br>"userName": "newuser", <br>"password": "secure-password" <br>} <br>
The new user will be created with the "User" role by default and can access
temperature data endpoints but cannot perform administrative functions.
RegisterAsync(Register, CancellationToken)¶
Registers a new user in the system. Admin access required.
Parameters¶
input Register
The registration data containing username and password for the new user.
cancellationToken CancellationToken
A cancellation token that can be used by other objects or threads to receive notice of cancellation.
Returns¶
User registered successfully.
Exceptions¶
ApiException
A server side error occurred.
Remarks:
This endpoint allows administrators to create new user accounts in the system.
Only users with the "Admin" role can access this endpoint.
Authorization Required: Bearer token with Admin role
Example request:
json <br>{ <br>"userName": "newuser", <br>"password": "secure-password" <br>} <br>
The new user will be created with the "User" role by default and can access
temperature data endpoints but cannot perform administrative functions.