Creating an application and obtaining an access token programmatically