Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
760 views
in Technique[技术] by (71.8m points)

android - com.parse.ParseRequest$ParseRequestException: invalid session token

Hello I am working on android app in which I am using parse cloud. I have signUp into the system then after I am trying to fetch data from parse.

But I am getting an exception everytime

com.parse.ParseRequest$ParseRequestException: invalid session token

String userName = ParseUser.getCurrentUser().getUsername();
ParseQuery<ParseObject> parseQuery = ParseQuery.getQuery("users");
parseQuery.findInBackground(new FindCallback<ParseObject>() {

    @Override
    public void done(List<ParseObject> list, ParseException parseException) {

    }
});

How we can resolve this problem.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Googling and Parse docs didn't give too much info about this exception, but There are few common mistakes I found. You should treat users as ParseUser, not ParseObject.

ParseQuery<ParseUser> query = ParseUser.getQuery();

One more case: need to specify what to find in background. If it is username, so write:

parseQuery.whereEqualTo("username", userName);

And finally callback will contain List with ParseUsers, not ParseObjects

query.findInBackground(new FindCallback<ParseUser>() {
  public void done(List<ParseUser> objects, ParseException e) {
  }
});

I'm not sure exception will be gone, but I hope this answer will be useful anyways.

Some useful links: doc with example, answer, Doc for class ParseQuery with examples

UPDATE

This is the official doc how to handle this error, also as I commented try to use ParseUser.enableRevocableSessionInBackground() after Parse.initialize(); According to the SDK Documentation it is gonna update session token and only one case it could be invalid - ParseObject was removed. Hope that helps.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...