devilcius / whatapi

Module to manage redacted.ch as a web service
5 stars 2 forks source link

Authentication Failure #1

Closed cohena closed 12 years ago

cohena commented 12 years ago

Hey, just tried testing out the API, and ran into a failure.

import whatapi whatcd = whatapi.getWhatcdNetwork('myusername', 'mypassword') whatcd.enableCaching() artist = whatcd.getArtist("Some band that exists") authenticating... creating cookie Traceback (most recent call last): File "", line 1, in File "whatapi.py", line 277, in getArtist return Artist(name, self) File "whatapi.py", line 911, in init WhatBase.init(self, whatcd) File "whatapi.py", line 150, in init self.whatcd.headers = Authenticate(self.whatcd).getAuthenticatedHeader() File "whatapi.py", line 428, in init self.getAuthenticatedHeader() File "whatapi.py", line 468, in getAuthenticatedHeader self.whatcd.authenticateduserinfo = self.getAuthenticatedUserInfo(homepage) File "whatapi.py", line 478, in getAuthenticatedUserInfo authuserinfo = self._parser().authenticatedUserInfo(homepage.find("div", {"id": "userinfo"})) File "whatapi.py", line 1055, in authenticatedUserInfo userInfo["authcode"] = regauth.search(hrefauth).group(0)[1:] AttributeError: 'NoneType' object has no attribute 'group'

devilcius commented 12 years ago

Just tested your code. It works fine. Have you downloaded the lastest version?

cohena commented 12 years ago

Yep, I just cloned from your repo last night. I wonder if this is somehow related to the newness of my account, it was just created yesterday.

I'm working on adding what.cd support to the Headphones project. The main project is at http://github.com/rembo10/headphones and my branch is at http://github.com/cohena/headphones under that what-search branch. I implemented most of it blind, and other users seem to be able to get past authentication.

I'm going to consult with Ajax (the user) on waffles, tonight, and see if there's something obvious I'm overlooking.

cohena commented 12 years ago

Aha, I found the source of my authentication problem. It turns out that the user authcode is not just hex values, as the regex searches for:

regauth = re.compile('=[0-9a-fA-F]+')

My authcode has the letters o, m, and q in it...I'm thinking that probably needs to be '=[0-9a-zA-Z]+'

devilcius commented 12 years ago

Nice one. I'll fix it right away.

devilcius commented 12 years ago

fixed and pushed