Okay so now that we can see the permissions are working for reading
objects when we're not authenticated what happens if we want to restrict this
API so only authenticated users can view it this is very common with many apps
you often will only want to limit certain api's for users who are
authenticated with the system and if you're not authenticated you don't want
to allow them to even read or view other objects so let's go ahead and modify our
feed API to ensure that users are authenticated to view it open up the
atom editor and then edit the views dot py file what we're going to do is we're
going to go to the top of the file and you can see here what we imported is
authenticated or read-only the Django rest framework has another handy
permission that comes with it by default just called is authenticated so we can
just remove this or read-only from the end and then that is the permission we
want to import so we just want to use the is authenticated permission which
blocks access to the entire endpoint unless the user is authenticated so now
let's scroll to the bottom of the file and update our permission classes
accordingly so let's remove the all read-only from this as well and then we
can actually reformat this because the length is shorter now so we'll reformat
it into one line to keep it neat and tidy and then save the file and that's
how you limit an API to authenticated users only