ofxHTTP
ofxHTTP copied to clipboard
OAuth10Credentials json issue
stable branch and oF 0.10.1
Hm. Odd, will take a look. Are you on macOS? If so, which version of Xcode, macOS, etc?
mac 10.14.4 xcode 10.2.1
Yeah, I haven't properly migrate my head from oxfJSON to nlohmann to advise yet, but it's something about the json deserialization values I think. Ended up commenting out this passage as not using SSL for this project.
As alway, I really appreciate your quality addons man.
Running into the same issue after upgrading to 10.14.6 from 10.14.3.
Hi @loganwilliams are you using the develop branch of ofxHTTP and its dependencies?
Also, have you tried upgrading your version of nlohmann::json like this https://github.com/bakercp/ofxSerializer/issues/1
@bakercp I am using the master
branch. And upgrading json.hpp
to 3.7.0 fixed it, thanks!
@loganwilliams good to know. The next release of OF should include a newer version of json.hpp
that offers better compatibility with newer macos compilers.
The issue is also present on Windows with Visual Studio 2019 (cl version 19.27.29112
), but newer version of json.hpp
doesn't fix it. I tried all the releases from v3.7.0
to v3.9.1
(after v3.8.0
everything breaks).
It turns out it's easily fixable, here's the working code :
OAuth10Credentials OAuth10Credentials::fromJSON(const ofJson& json)
{
OAuth10Credentials credentials;
auto iter = json.cbegin();
while (iter != json.cend())
{
const auto& key = iter.key();
const auto& value = iter.value();
// just add .get<std::string>() for each assignment
if (key == "consumerKey") credentials._consumerKey = value.get<std::string>();
else if (key == "consumerSecret" || key == "consumer_secret")
credentials._consumerSecret = value.get<std::string>();
else if (key == "accessToken" || key == "access_token")
credentials._accessToken = value.get<std::string>();
else if (key == "accessTokenSecret" || key == "access_token_secret")
credentials._accessTokenSecret = value.get<std::string>();
else if (key == "owner")
credentials._owner = value.get<std::string>();
else if (key == "ownerId" || key == "owner_id")
credentials._ownerId = value.get<std::string>();
else ofLogWarning("Credentials::fromJSON") << "Unknown key: " << key << std::endl << value.dump(4);
++iter;
}
return credentials;
}
It's working with json.hpp
version 3.7.0.