Fix oauth2 middleware compatibility with draft-ietf-oauth-v2-31 spec.