Need some clarification here. I was assuming, that the token will be used to extract username/password and then rest of the code will be used to return the auth block. 

Are you suggesting something else here?