Start a new topic

How to access a file while user does not exist yet / is not logged in yet

Hi there, 

My app needs to show some disclaimer text when launched for the first time. Because the content may vary often, I use a file hosted on Kinvey, I can easily update based on legals inputs without touching the client side. This file has been uploaded through the console, has a version number, and other columns. Also, I have set the "_public" to true.

Now, if the user is logged in, I can access this file just fine doing a query like: give me the files for which version > last known version AND language = English, for instance. No problem.

But, as a disclaimer it should be displayed even before a user is created. Where doing the query above, I get the following error: "You need to be logged in to execute this request"

How can I get the file while there is no user logged in yet?

1 Comment

Hi Christophe,

As of today, a user session is necessary to call any Kinvey API (collections, files etc.)

So, you have following alternatives to achieve this:

  1. Hard code "the download link" of the disclaimer file ( _public is true ) inside the app
  2. Use a common service account to access the disclaimer file when the real user is not logged in
  3. Store this particular file outside Kinvey (e.g. a publicly readable dropbox file)

A common service account will give you the benefit of maintaining all the versions of the disclaimer file, with language specific variations.

I hope this helps.

Login or Signup to post a comment