milesrichardson / ParsePy

A relatively up-to-date fork of ParsePy, the Python wrapper for the Parse.com API. Originally maintained by @dgrtwo
MIT License
516 stars 184 forks source link

Running into - ResourceRequestNotFound: {"code":101,"error":"invalid session"} #109

Closed rohitdotmittal closed 9 years ago

rohitdotmittal commented 9 years ago

The user logs and may perform a few requests but after some time they end up with ResourceRequestNotFound: {"code":101,"error":"invalid session"} I guess this is because the user is logged out or sessionToken is lost. I'm using flask for this.

  File "/Library/Python/2.7/site-packages/flask/app.py", line 1836, in __call__
    return self.wsgi_app(environ, start_response)
  File "/Library/Python/2.7/site-packages/flask/app.py", line 1820, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "/Library/Python/2.7/site-packages/flask/app.py", line 1403, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/Library/Python/2.7/site-packages/flask/app.py", line 1817, in wsgi_app
    response = self.full_dispatch_request()
  File "/Library/Python/2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/Library/Python/2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/Library/Python/2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Library/Python/2.7/site-packages/flask/app.py", line 1461, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/Users/rohitmittal/Downloads/NewResikshaServer/stilt_api.py", line 79, in get_current_user
    current_user = User.current_user()
  File "/Library/Python/2.7/site-packages/parse_rest/user.py", line 97, in current_user
    return cls(**User.GET(user_url))
  File "/Library/Python/2.7/site-packages/parse_rest/connection.py", line 133, in GET
    return cls.execute(uri, 'GET', **kw)
  File "/Library/Python/2.7/site-packages/parse_rest/connection.py", line 127, in execute
    raise exc(e.read())
ResourceRequestNotFound: {"code":101,"error":"invalid session"}
dankrause commented 9 years ago

When the user's token expires, you need them to authenticate again, so you can get a new token. Just catch the ResourceRequestNotFound, look for "invalid session", and prompt the user for their password again.

This isn't something ParsePy can do for you, since the users password isn't stored anywhere. You'll need to prompt for it every time the session expires.

rohitdotmittal commented 9 years ago

I should've mentioned that it happens while Parse session tokens are still valid. It was a flask issue. Flask wasn't storing session tokens. Thanks for the input though!