跳转至

Class qqmusic::utils::Credential

ClassList > qqmusic > utils > Credential

凭据信息类

  • #include <credential.h>

Public Attributes

Type Name
std::string access_token
AccessToken
std::string encryptUin
加密的euin, euin和账号ID一一对应
uint64_t expired_at = 0
到期时间, 秒级时间戳
nlohmann::json extra_fields
没有收录在上面的字段
int loginType = 2
登录模式 1 : 微信登陆2 : QQ登陆
uint64_t musicid = 0
账号MusicID, 一般是QQ号
std::string musickey
账号MusicKey
std::string openid
OpenID
std::string refresh_key
RefreshKey
std::string refresh_token
RefreshToken
std::string str_musicid
std::string格式的账号MusicID, 一般是QQ号
std::string unionid
UnionID

Public Functions

Type Name
Credential () = default
默认空初始化
Credential (std::string_view cookie)
从login api获取的返回结果构造Credential
Credential (nlohmann::json & cookie)
从login api返回的结果构造Credential
NLOHMANN_DEFINE_TYPE_INTRUSIVE (Credential, openid, refresh_token, access_token, expired_at, musicid, unionid, str_musicid, musickey, refresh_key, encryptUin, loginType)
bool from_cache (std::string_view cache)
从序列化出的cache生成Credential
bool from_cache (nlohmann::json & cache)
从序列化出的cache生成Credential
qqmusic::Task< qqmusic::Result< bool > > is_expired ()
判断Credential是否过期
bool is_valid () const
判断Credential是否合法, 即有没有 musicid musickey 字段
qqmusic::Task< qqmusic::Result< void > > refresh ()
刷新Credential
qqmusic::Result< nlohmann::json > to_json ()
将Credential序列化为Json对象
qqmusic::Result< std::string > to_string ()
将Credential序列化为Json字符串

Public Attributes Documentation

variable access_token

AccessToken

std::string qqmusic::utils::Credential::access_token;


variable encryptUin

加密的euin, euin和账号ID一一对应

std::string qqmusic::utils::Credential::encryptUin;


variable expired_at

到期时间, 秒级时间戳

uint64_t qqmusic::utils::Credential::expired_at;


variable extra_fields

没有收录在上面的字段

nlohmann::json qqmusic::utils::Credential::extra_fields;


variable loginType

登录模式 1 : 微信登陆2 : QQ登陆

int qqmusic::utils::Credential::loginType;


variable musicid

账号MusicID, 一般是QQ号

uint64_t qqmusic::utils::Credential::musicid;

Note:

常用字段


variable musickey

账号MusicKey

std::string qqmusic::utils::Credential::musickey;

Note:

常用


variable openid

OpenID

std::string qqmusic::utils::Credential::openid;


variable refresh_key

RefreshKey

std::string qqmusic::utils::Credential::refresh_key;


variable refresh_token

RefreshToken

std::string qqmusic::utils::Credential::refresh_token;


variable str_musicid

std::string格式的账号MusicID, 一般是QQ号

std::string qqmusic::utils::Credential::str_musicid;

Note:

常用字段


variable unionid

UnionID

std::string qqmusic::utils::Credential::unionid;


Public Functions Documentation

function Credential [1/3]

默认空初始化

qqmusic::utils::Credential::Credential () = default


function Credential [2/3]

从login api获取的返回结果构造Credential

explicit qqmusic::utils::Credential::Credential (
    std::string_view cookie
) 

Parameters:

  • cookie Json字符串

function Credential [3/3]

从login api返回的结果构造Credential

explicit qqmusic::utils::Credential::Credential (
    nlohmann::json & cookie
) 

Parameters:

  • cookie Json对象

function NLOHMANN_DEFINE_TYPE_INTRUSIVE

qqmusic::utils::Credential::NLOHMANN_DEFINE_TYPE_INTRUSIVE (
    Credential,
    openid,
    refresh_token,
    access_token,
    expired_at,
    musicid,
    unionid,
    str_musicid,
    musickey,
    refresh_key,
    encryptUin,
    loginType
) 

function from_cache [1/2]

从序列化出的cache生成Credential

bool qqmusic::utils::Credential::from_cache (
    std::string_view cache
) 

Parameters:

  • cacheCredential::to_string()Credential::to_json() 生成的序列化结果导入Credential

Returns:

true, 如果处理过程出现问题 false, 如果正常处理完毕


function from_cache [2/2]

从序列化出的cache生成Credential

bool qqmusic::utils::Credential::from_cache (
    nlohmann::json & cache
) 

Parameters:

  • cacheCredential::to_string()Credential::to_json() 生成的序列化结果导入Credential

Returns:

true, 如果处理过程出现问题 false, 如果正常处理完毕


function is_expired

判断Credential是否过期

qqmusic::Task< qqmusic::Result< bool > > qqmusic::utils::Credential::is_expired () 

Returns:

包含正确JSON格式结果的Task< Result <bool>>. 如果产生错误, 返回值包含错误结果和错误类型枚举 返回true说明未过期, false说明过期, 需要刷新

Note:

异步函数, 返回Task


function is_valid

判断Credential是否合法, 即有没有 musicid musickey 字段

bool qqmusic::utils::Credential::is_valid () const

Returns:

true, 合法 false, 不合法


function refresh

刷新Credential

qqmusic::Task< qqmusic::Result< void > > qqmusic::utils::Credential::refresh () 

Returns:

包含正确JSON格式结果的Task< Result <void>>. 如果产生错误, 返回值包含错误结果和错误类型枚举

Note:

异步函数, 返回Task


function to_json

将Credential序列化为Json对象

qqmusic::Result< nlohmann::json > qqmusic::utils::Credential::to_json () 

Returns:

包含结果或错误的Result <nlohmann::json>


function to_string

将Credential序列化为Json字符串

qqmusic::Result< std::string > qqmusic::utils::Credential::to_string () 

Returns:

包含结果或错误的Result <std::string>



The documentation for this class was generated from the following file include/qqmusic/utils/credential.h