Umm what are you trying to do exactly? I know you're trying to get a login system to work, but for what? From my understanding the API is for mobile use. If you're trying to login on a standard website there is much better ways to do it. The main problem seems to be that the directory isn't set.
https://vborg.vbsupport.ru/showthread.php?t=173698
great way to do it, and it works just the same on vB.