When I sent a request to OAuth 2.0 Authorization server to get authorization code, I am sending an encoded state property in the url. The redirected response as per Google's documentation, should also contain encoded state value in the url.
For example, My request url is
https://accounts.google.com/o/oauth2/v2/auth?scope=https%3A//www.googleapis.com/auth/drive.metadata.readonly&state=https%3A%2F%2Fmydomain%3A8383%2Fhtml%2Foauth-verification.html&redirect_uri=https%3A//oauth2.example.com/code&access_type=offline&response_type=code&client_id=583306224539-atbcaa8ne8g85e8kc006o6vmq99qiid0.apps.googleusercontent.com
This should redirect to,
https://oauth2.example.com/code?state=https%3A%2F%2Fmydomain%3A8383%2Fhtml%2Foauth-verification.html&code=4/0ARtbhnkIrVcHpI3NCb1J3-JRWLsJ6JVX5Nd7JHmNAKVL4aYJlz_s9yf9MPn2MJtymuEk_g&scope=https://www.googleapis.com/auth/drive.metadata.readonly
But it decodes the state parameter and redirects to,
https://oauth2.example.com/code?state=https://mydomain:8383/html/oauth-verification.html&code=4/0ARtbhnkIrVcHpI3NCb1J3-JRWLsJ6JVX5Nd7JHmNAKVL4aYJlz_s9yf9MPn2MJtymuEk_g&scope=https://www.googleapis.com/auth/drive.metadata.readonly