Skip to content

Commit 8fef5fc

Browse files
committed
Added support for casting 'expires_in' JSON field from string to int64.
1 parent b462fe4 commit 8fef5fc

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Release/src/http/oauth/oauth2.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,16 @@ 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-
result.set_expires_in(token_json.at(oauth2_strings::expires_in).as_number().to_int64());
190+
auto json_expires_in_val = token_json.at(oauth2_strings::expires_in);
191+
192+
if (json_expires_in_val.is_number())
193+
result.set_expires_in(json_expires_in_val.as_number().to_int64());
194+
else
195+
{
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()));
199+
}
191200
}
192201
else
193202
{

0 commit comments

Comments
 (0)