Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OAuth10Credentials json issue #51

Open
borg opened this issue May 29, 2019 · 10 comments
Open

OAuth10Credentials json issue #51

borg opened this issue May 29, 2019 · 10 comments

Comments

@borg
Copy link

borg commented May 29, 2019

image

@borg
Copy link
Author

borg commented May 29, 2019

stable branch and oF 0.10.1

@bakercp
Copy link
Owner

bakercp commented May 29, 2019

Hm. Odd, will take a look. Are you on macOS? If so, which version of Xcode, macOS, etc?

@borg
Copy link
Author

borg commented May 30, 2019

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.

@loganwilliams
Copy link

Running into the same issue after upgrading to 10.14.6 from 10.14.3.

@bakercp
Copy link
Owner

bakercp commented Sep 16, 2019

Hi @loganwilliams are you using the develop branch of ofxHTTP and its dependencies?

@bakercp
Copy link
Owner

bakercp commented Sep 16, 2019

Also, have you tried upgrading your version of nlohmann::json like this bakercp/ofxSerializer#1

@loganwilliams
Copy link

@bakercp I am using the master branch. And upgrading json.hpp to 3.7.0 fixed it, thanks!

@bakercp
Copy link
Owner

bakercp commented Sep 17, 2019

@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.

@loics2
Copy link

loics2 commented Oct 26, 2020

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).

@loics2
Copy link

loics2 commented Oct 26, 2020

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.

loics2 added a commit to loics2/ofxHTTP that referenced this issue Oct 26, 2020
This commit fixes compilation issues on MacOS and Windows described in
issue bakercp#51.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants