Added custom user agent and fixed a bug with redirect uri