Finally got authentication working