1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
// THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
#pragma once
#include <Quotient/jobs/basejob.h>
namespace Quotient {
//! \brief Refresh an access token
//!
//! Refresh an access token. Clients should use the returned access token
//! when making subsequent API calls, and store the returned refresh token
//! (if given) in order to refresh the new access token when necessary.
//!
//! After an access token has been refreshed, a server can choose to
//! invalidate the old access token immediately, or can choose not to, for
//! example if the access token would expire soon anyways. Clients should
//! not make any assumptions about the old access token still being valid,
//! and should use the newly provided access token instead.
//!
//! The old refresh token remains valid until the new access token or refresh token
//! is used, at which point the old refresh token is revoked.
//!
//! Note that this endpoint does not require authentication via an
//! access token. Authentication is provided via the refresh token.
//!
//! Application Service identity assertion is disabled for this endpoint.
class QUOTIENT_API RefreshJob : public BaseJob {
public:
//! \param refreshToken
//! The refresh token
explicit RefreshJob(const QString& refreshToken);
// Result properties
//! The new access token to use.
QString accessToken() const { return loadFromJson<QString>("access_token"_L1); }
//! The new refresh token to use when the access token needs to
//! be refreshed again. If not given, the old refresh token can
//! be re-used.
QString refreshToken() const { return loadFromJson<QString>("refresh_token"_L1); }
//! The lifetime of the access token, in milliseconds. If not
//! given, the client can assume that the access token will not
//! expire.
std::optional<int> expiresInMs() const
{
return loadFromJson<std::optional<int>>("expires_in_ms"_L1);
}
struct Response {
//! The new access token to use.
QString accessToken{};
//! The new refresh token to use when the access token needs to
//! be refreshed again. If not given, the old refresh token can
//! be re-used.
QString refreshToken{};
//! The lifetime of the access token, in milliseconds. If not
//! given, the client can assume that the access token will not
//! expire.
std::optional<int> expiresInMs{};
};
};
template <std::derived_from<RefreshJob> JobT>
constexpr inline auto doCollectResponse<JobT> = [](JobT* j) -> RefreshJob::Response {
return { j->accessToken(), j->refreshToken(), j->expiresInMs() };
};
} // namespace Quotient
|