Rewritten the OAuth 2 client example to make it robust and reusable