Skip to content

Commit c0e31f0

Browse files
authored
Add type checks to oauth2 parsing code
1 parent 28919d0 commit c0e31f0

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Release/src/http/oauth/oauth2.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ oauth2_token oauth2_config::_parse_token_from_json(const json::value& token_json
149149
{
150150
oauth2_token result;
151151

152-
if (token_json.has_field(oauth2_strings::access_token))
152+
if (token_json.has_string_field(oauth2_strings::access_token))
153153
{
154154
result.set_access_token(token_json.at(oauth2_strings::access_token).as_string());
155155
}
@@ -158,7 +158,7 @@ oauth2_token oauth2_config::_parse_token_from_json(const json::value& token_json
158158
throw oauth2_exception(U("response json contains no 'access_token': ") + token_json.serialize());
159159
}
160160

161-
if (token_json.has_field(oauth2_strings::token_type))
161+
if (token_json.has_string_field(oauth2_strings::token_type))
162162
{
163163
result.set_token_type(token_json.at(oauth2_strings::token_type).as_string());
164164
}
@@ -174,7 +174,7 @@ oauth2_token oauth2_config::_parse_token_from_json(const json::value& token_json
174174
throw oauth2_exception(U("only 'token_type=bearer' access tokens are currently supported: ") + token_json.serialize());
175175
}
176176

177-
if (token_json.has_field(oauth2_strings::refresh_token))
177+
if (token_json.has_string_field(oauth2_strings::refresh_token))
178178
{
179179
result.set_refresh_token(token_json.at(oauth2_strings::refresh_token).as_string());
180180
}
@@ -205,7 +205,7 @@ oauth2_token oauth2_config::_parse_token_from_json(const json::value& token_json
205205
result.set_expires_in(oauth2_token::undefined_expiration);
206206
}
207207

208-
if (token_json.has_field(oauth2_strings::scope))
208+
if (token_json.has_string_field(oauth2_strings::scope))
209209
{
210210
// The authorization server may return different scope from the one requested.
211211
// This however doesn't necessarily mean the token authorization scope is different.

0 commit comments

Comments
 (0)