Skip to content

Commit f56eca5

Browse files
committed
Removing usage of std::stoll which isn't avaliable on Android.
1 parent 8fef5fc commit f56eca5

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Release/src/http/oauth/oauth2.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,15 +187,19 @@ oauth2_token oauth2_config::_parse_token_from_json(const json::value& token_json
187187

188188
if (token_json.has_field(oauth2_strings::expires_in))
189189
{
190-
auto json_expires_in_val = token_json.at(oauth2_strings::expires_in);
190+
const auto &json_expires_in_val = token_json.at(oauth2_strings::expires_in);
191191

192192
if (json_expires_in_val.is_number())
193193
result.set_expires_in(json_expires_in_val.as_number().to_int64());
194194
else
195195
{
196-
// handle the case of a number as a JSON "string".
197-
// std::stoll() will throw an exception if no conversion is possible.
198-
result.set_expires_in(std::stoll(json_expires_in_val.as_string()));
196+
// Handle the case of a number as a JSON "string".
197+
// Using streams because std::stoll isn't avaliable on Android.
198+
int64_t expires;
199+
utility::istringstream_t iss(json_expires_in_val.as_string());
200+
iss.exceptions(std::ios::badbit | std::ios::failbit);
201+
iss >> expires;
202+
result.set_expires_in(expires);
199203
}
200204
}
201205
else

0 commit comments

Comments
 (0)