Please check your redirect_uri that you are passing at the time of token generation, the redirect_uri should be same as that of successful code generation. This will help you fix the token generation error. Please update us if this resolves the issue.
On our end we will have a fix for this error message invalid authorization code by this month end release.