added initial api logic / oauth2 and fixed some issues