Integrity verification failed on token endpoint

Problem

When exchanging an authorization code for an access token using a post request to the token endpoint,  the following error occurs:


{"error_description":"Integrity verification failed","error":"invalid_grant"}

Solution

This error indicates that the authorization code used has been mangled somehow or encoded badly. Verify that the value in the code parameter returned from the authorization request matches exactly the value used.