Forums

HTTP Error 403 through web2py

I'm having a problem where urllib2.urlopen() returns "HTTP Error 403" when I invoke my code as a web app through web2py (the same code runs flawlessly when run through the pythonanywhere IDE); the link is straight http (not https). Now, I recognize this error code: when I encountered it before I realized that I had to upgrade my account to access sites not on the whitelist, and I have since done so. I speculate that the problem is that when I try to run my code in a web app the user is deemed to be an anonymous "somebody" rather than "me" (who paid for an account upgrade).

My questions then:

Is my speculation correct, or is there something else causing this error code?

Any suggestions on how to rectify this? Is there any way to get my code to "run as" me when it is accessed over the web?

The code does run as you, but it looks like for some reason it was still using the proxy. Had you restarted the web app since you upgraded? (I see that was quite recently). If you had restarted it, then we have some kind of nasty bug -- if you hadn't, it just means that we need to either tell people that they should restart their web apps after upgrading to get access to the new features, or even better automatically restart the web apps.

Either way, sorry for the confusion! I've restarted the app now and double-checked that it reconfigured itself to access directly -- without a proxy -- and I've confirmed that your user account has proxy-less access to the Internet, so it should work fine now.

In fact I hadn't even created the web2py application until after I upgraded my account (I upgraded while I was still tinkering in the IDE). That being said, it's running as it should now - thanks very much for the quick and effective help.

Also, let me add my voice to the chorus of pythonanywhere lovers - with support like this you guys can't fail to take over the world (that was your goal, right?).

Thanks, we do our best! World domination is definitely our first goal. Then we can spend our ill-gotten gains on building a spaceship or two so that we can take over the rest of the solar system...

Thanks for the further information, that's actually doubly curious -- when you created the web2py app, it should have deleted all of the old settings and recreated the new app based on your upgraded settings. I'll have to poke around a bit more and see if I can reproduce the problem, obviously something went wrong...

I'd like to command the ship a2j when we are ready for our other world exploration.

@geoffham: Oh, and I almost forgot. Welcome to PA...☺

Obviously the navigation system will need to be written in Python, so we'd better start work on a CPU which executes Python byte code natively (presumably driving content addressable memory).

Now how's that for a little spare-time project? (^_^)

@Cartroo -- nice -- almost Redis in hardware!

@a2j -- the good ship a2j is reserved for you.