Integrate authenticate service into javascript code