Skip to content

oauthUser.saveIdentity() does not work #7

@bharatdodeja

Description

@bharatdodeja

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions