Fixing token-retrieval flow.

Changes to ensure the exchange of authorization code for access token works properly.