By design in order to create content through the API the user should be logged in as administrator in the backend of the project.
If you are not logged as administrator you can set the SuppressSecurityChecks property of the provider to true, in order to skip the permissions check of the provider and to be able to execute the code with anonymous identity.
However, in your case you can comment out the lines that set the SuppressSecurityChecks property since in the sample code we query pages from the database and this code can be executed by an anonymous identity. I updated the KB article accordingly.
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal
and vote to affect the priority of the items