解析 Android - 推特登录后 getCurrentUser() objectId 为空 [英] Parse Android - getCurrentUser() objectId is null after twitter login

查看:30
本文介绍了解析 Android - 推特登录后 getCurrentUser() objectId 为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 ParseTwitterUtils.logIn(..) 通过 Twitter 登录用户.调用回调函数时 ParseUser.getCurrentUser().getObjectId() 为空.

I'm using ParseTwitterUtils.logIn(..) for logging in the user through twitter. When the callback function is called ParseUser.getCurrentUser().getObjectId() is null.

如果用户使用 twitter 成功登录,假设我有一个用户使用相同的用户名和 twitter authData 保存在服务器上,当前用户不应该得到一个对象 ID 吗?

If the user successfully logged in with twitter shouldn't the current user get an object id assuming that I have a user saved on the server with that same username and twitter authData ?

ParseTwitterUtils.logIn(this, new LogInCallback() {

    @Override
    public void done(ParseUser parseUser, ParseException ex) {
        ParseUser user = ParseUser.getCurrentUser();
        String objectId = user.getObjectId(); //objectId is null

        String loggedInObjectId = parseUser.getObjectId(); //loggedInObjectId is null too
    }
});

此外,ex 为空.表示查询已成功执行.

Also, ex is null. Meaning the query was executed successfully.

推荐答案

我终于找到了问题所在.如果您在设置 -> 用户身份验证设置下的解析设置中指定消费者密钥,并使用不同的 twitter 应用程序,解析不会抛出任何错误,但它会返回一个内容为空的 ParseUser.

I finally found the problem. If you specify a consumer key in Parse Settings under Settings -> User Authentication Settings, and use different twitter app, Parse won't throw any errors but it will return a ParseUser with empty content.

确保将消费者密钥字段留空或使用正确的密钥.

Make sure you leave the consumer key field blank or use a proper key.

这篇关于解析 Android - 推特登录后 getCurrentUser() objectId 为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆