diff --git a/libtransport/OAuth2.cpp b/libtransport/OAuth2.cpp index 6b3841c7fd568ce18ad047d0441484cfeb37d657..219623f072363f626a14b4ac0fe1958d419f478a 100644 --- a/libtransport/OAuth2.cpp +++ b/libtransport/OAuth2.cpp @@ -71,7 +71,7 @@ std::string OAuth2::generateAuthURL() { return url; } -std::string OAuth2::requestToken(const std::string &code, std::string &token) { +std::string OAuth2::requestToken(const std::string &code, std::string &token, std::string &bot_token) { std::string url = m_tokenURL + "?"; url += "client_id=" + Util::urlencode(m_clientId); url += "&client_secret=" + Util::urlencode(m_clientSecret); @@ -105,6 +105,14 @@ std::string OAuth2::requestToken(const std::string &code, std::string &token) { return "Empty 'access_token' object in the reply."; } + rapidjson::Value& bot = resp["bot"]; + if (bot.IsObject()) { + rapidjson::Value& bot_access_token = resp["bot_access_token"]; + if (!bot_access_token.IsString()) { + bot_token = bot_access_token.GetString(); + } + } + return ""; }