if (!*self->auth.refresh_token)
return -ENOTSUP;
+ // Log action
+ DEBUG(self->ctx, "Refreshing authentication tokens...\n");
+
// Create a new transfer
r = pakfire_client_xfer_create(&xfer, self, "/api/v1/auth/refresh");
if (r < 0)
return r;
}
-static int pakfire_client_access_timer(sd_event_source* event, uint64_t usec, void* data) {
+static int pakfire_client_refresh_timer(sd_event_source* event, uint64_t usec, void* data) {
struct pakfire_client* self = data;
- DEBUG(self->ctx, "Authentication access timer fired\n");
-
- return 0;
+ // Refresh the authentication tokens
+ return pakfire_client_auth_refresh(self);
}
static int pakfire_client_set_access_token(struct pakfire_client* self, const char* token) {
// Create the access token timer (unless already done so)
if (!self->auth.access_timer) {
r = sd_event_add_time_relative(self->loop, &self->auth.access_timer,
- CLOCK_MONOTONIC, 0, 0, pakfire_client_access_timer, self);
+ CLOCK_MONOTONIC, 0, 0, pakfire_client_refresh_timer, self);
if (r < 0) {
ERROR(self->ctx, "Failed to register the auth access timer: %s\n", strerror(-r));
return r;
return 0;
}
-static int pakfire_client_refresh_timer(sd_event_source* event, uint64_t usec, void* data) {
- struct pakfire_client* self = data;
-
- DEBUG(self->ctx, "Authentication refresh timer fired\n");
-
- return 0;
-}
-
static int pakfire_client_set_refresh_token(struct pakfire_client* self, const char* token) {
time_t expires_at = -1;
int r;