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

oauthUser.saveIdentity() does not work #7

Open
bharatdodeja opened this issue Dec 7, 2015 · 0 comments
Open

oauthUser.saveIdentity() does not work #7

bharatdodeja opened this issue Dec 7, 2015 · 0 comments

Comments

@bharatdodeja
Copy link

I want to save some custom data for the stormpath user account. As explained in the docs, I have called saveIdentity() of OAuthUser class after setting some data as below:

OAuthUser user = users.getIdentity();
        user.data.put("location", "Pune, India");
        user.data.put("gender", "Male");
        user.saveIdentity(new OAuthUserCallback() {
            @Override
            public void onFinished() {
            }
            @Override
            public void onError(String message) {
            }
        });

When I looked inside the method definition, I have found that it does not call post rather it calls get() of OAuthJSONRequest class.

 public void saveIdentity(final OAuthUserCallback callback) {
        String url =  _oauth.getOAuthdURL() + "/api/usermanagement/user?k=" + _oauth.getPublicKey() + "&token=" + token;

        JSONObject postdata = new JSONObject();
        try {
            Iterator it = data.keySet().iterator();
            while (it.hasNext()) {
                String key = (String) it.next();
                postdata.put(key, data.get(key));
            }
        } catch (JSONException e) {
            callback.onError(e.getMessage());
            return;
        }

        new OAuthJSONRequest().get(url, new OAuthJSONCallback() {
            @Override
            public void onFinished(JSONObject data) {
                callback.onFinished();
            }

            @Override
            public void onError(String message) {
                callback.onError(message);
            }
        });
    }

Link to StackOverflow question: http://stackoverflow.com/q/34082103/1567675

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

1 participant