Mercurial > minori
comparison src/services/kitsu.cc @ 352:a0e96f50bcce
chore: merge diverging branches
| author | Paper <paper@paper.us.eu.org> |
|---|---|
| date | Sun, 14 Jul 2024 23:24:19 -0400 |
| parents | 7e97c566cce4 |
| children | 47c9f8502269 |
comparison
equal
deleted
inserted
replaced
| 351:c844f8bb87ce | 352:a0e96f50bcce |
|---|---|
| 84 /* the next two are not that important */ | 84 /* the next two are not that important */ |
| 85 | 85 |
| 86 return true; | 86 return true; |
| 87 } | 87 } |
| 88 | 88 |
| 89 static bool RefreshAccessToken(std::string& access_token, const std::string& refresh_token) { | 89 static bool RefreshAccessToken(void) { |
| 90 const nlohmann::json request = { | 90 const nlohmann::json request = { |
| 91 {"grant_type", "refresh_token"}, | 91 {"grant_type", "refresh_token"}, |
| 92 {"refresh_token", refresh_token} | 92 {"refresh_token", session.config.auth.kitsu.refresh_token}, |
| 93 }; | 93 }; |
| 94 | 94 |
| 95 if (!SendAuthRequest(request)) | 95 if (!SendAuthRequest(request)) |
| 96 return false; | 96 return false; |
| 97 | 97 |
| 102 | 102 |
| 103 static std::optional<std::string> AccountAccessToken() { | 103 static std::optional<std::string> AccountAccessToken() { |
| 104 auto& auth = session.config.auth.kitsu; | 104 auto& auth = session.config.auth.kitsu; |
| 105 | 105 |
| 106 if (Time::GetSystemTime() >= session.config.auth.kitsu.access_token_expiration) | 106 if (Time::GetSystemTime() >= session.config.auth.kitsu.access_token_expiration) |
| 107 if (!RefreshAccessToken(auth.access_token, auth.refresh_token)) | 107 if (!RefreshAccessToken()) |
| 108 return std::nullopt; | 108 return std::nullopt; |
| 109 | 109 |
| 110 return auth.access_token; | 110 return auth.access_token; |
| 111 } | 111 } |
| 112 | 112 |
