Why does my web2py app keep logging me out - python

I recently deployed a web2py app, and am going through the debugging phase. Part of the app includes an auth.wiki, which mostly works great. Last night I added several pages to the wiki with no problems.
However, today, whenever I navigate to the wiki or try to edit a page, I'm immediately logged out.
Any suggestions? I can't interact with the wiki if I'm not logged in...
EDIT: It's not just the wiki, I keep getting logged out of the whole site. Other users do not have this problem. It continues even when I select "remember me for 30 days" on login.

Your comment hints at the answer: When you log into the admin session, when you refresh your website, it is now accessed through the admin session, which has no client user logged in.
One solution is to use different browsers for admin and a different browser for client.

Related

Allow multiple users to login at the same time in Django project

I am working on a django project and I have completed working on it. And I tested it and ran the project in on two webpages in chrome with my localhost:8000 server . I logged in in first page as a first user , lets say user1 and logged in on another page with another username , lets say user2 . But when I refresh the first page , the user1 is not logged in and I get logged in as the user2. The first page user1 is not logged in . I want to login multiple users at the same time so I can interact with the page. Kindly help me .
When the user logs in, django stores information on the browser, which is why this happens. What you can do is open up a private window private window, and have the second user log in there. You can also use another browser to test out a third user. There might be a more efficient method, but this is quick an d simple solution.
UPDATE
After a bit of checking I found a much better solution to the question. Ghost Browser was made for this specific situation. And since as of now this does not work in Linux, you can also use extensions in Firefox, like Temporary Containers, and there probably are similar extensions for other browsers.

Publishing videos to Facebook Page as Page - publish_stream and manage_pages permissions not working

Attempting to write a simple server-side Python script that posts videos to a Facebook page (not a personal page, but a sports team page that I have admin permissions for). The script works perfectly when uploading videos to my own personal FB page, and other FB pages that I created — but I keep getting this error:
OAuthError: [200] (#200) Subject does not have permission to post videos on this page
When attempting to post videos with the script to a page that I do have admin permission for, but I didn't create (pointing that out because it's a consistent difference in the oauth response I keep seeing, assuming maybe page creation has something to do with this?).
I have tried using facepy, which is a great Python library for Facebook, but so far no luck in resolving this issue.
I know that responses to questions related to this topic from a few years ago mention that:
To publish to Page as User you need publish_stream permission granted
by User.
To publish to Page as Page you need publish_stream and manage_pages
permissions granted by User and Page access_token which can be
retrieved from accounts connection of user.
But when creating a token for my app using Facebook's Graph API Explorer, all of these permission are enabled/checked off, every single one, but still the same permissions error.
Has anyone seen anything like this?
Solution to this is here:
facebook: permanent Page Access Token?
For anyone trying to develop a strictly server-side app for automated video uploads via cron job to a page, carefully follow the steps outlined by donut's answer in the linked post.
You need add this permission publish_actions in https://developers.facebook.com/apps/ in status and review items.

Django - Confirmation on first visit

In my new django project, I want the visitors to confirm the terms and condition before visiting a specific site, but this should only happen on the first time they visit the site. They don't have to be logged in, I will have to do this with cookies I think. Any ideas?
If you google for django cookie law you'll find several different options.
One of these options is django-cookie-law.

Setting Django test cookie on every page

I am not a Django nor a Python programmer (I do know Perl, PHP, and Javascript pretty well though). I was given a Django site to work on and I understand the templating really well, I just never touch any actual Python code. My client wants a log-in on every page of the site, which is easy to do… but often when a user logs in, they get the error message "Your Web browser doesn't appear to have cookies enabled. Cookies are required for logging in." I guess that's because a test cookie is set when you go to the Django log-in page, and then when you log in, it checks for it. If you're not logging in from the log-in page/don't have the cookie set, you get the error. I tried a hack to load the login page in the background via AJAX to set the cookie and that for some reason only works about 50% of the time. Are there any Django/Python experts out there who can tell me step-by-step what a non-hack way would be to prevent this error from coming up?
Check this question for how to use Django to set persistent cookies.
Also check this question for how to get cookies.
I think the solution you need is the combination of both; create a test cookie under any name, set it, and then check to see if it exists prior to generating your view.

Facebook calling Google App Engine code using GET instead of POST

I've been developing a Facebook app using Google App Engine in Python and the pyfacebook bindings. For weeks everything worked fine but suddenly it stopped.
At first I thought it was a code change so I rolled back the entire dev directory to a version I knew worked, but still it failed. It's possible a change I made to the application's settings caused the issue but, if so, I can't figure out what.
I've figured out that the problem is that instead of calling the post(self) method of my Main class, Facebook is calling using a GET.
Does anyone know why Facebook would use a GET method instead of a POST? It's an IFrame app.
Thanks,
The typical flow for a user when using the application begins with the user landing at some Canvas URL, like http://apps.facebook.com/runwithfriends/. At this point, Facebook will load up it's chrome, and render a tag to your application. You'll notice there isn't a src specified. Using some JavaScript and the tag, Facebook triggers a POST request to your application. This is done for security reasons, as the sensitive user data won't be sent via the HTTP Referrer header as long it's sent as POST data.
Although I'm not completely sure this was the cause, it appears I changed from an FBML app to an IFrame app. FBML mode relies on POST calls but IFrame appears to use GET. I'm inferring this answer from what I read here as well as from the observations I'm seeing and this being the only answer that makes any sense.

Categories