Auth0 Home Blog Docs

Error Response: 'Failed to verify code verifier' from server

#1

I use following approach for social sign in.

    WebAuthProvider.init(auth0)
            .withScheme("com.myapp.app")
            .withAudience("http://goo.gl")
            .withParameters(map)
            .withConnection("google-oauth2")
            .withScope("openid profile email offline_access")
            .start(activity, webCallback);

After sign in i get code in my activity by doing following.

    if (getIntent().getData() != null) {
       String code= getIntent().getData().getQueryParameter("code");

}

Till now everything is good, now i need code_verifier. I am using following approach to get code_verifier.

    SecureRandom sr = new SecureRandom();
    byte[] code = new byte[32];
    sr.nextBytes(code);
    String verifier = Base64.encodeToString(code, Base64.URL_SAFE | Base64.NO_WRAP | Base64.NO_PADDING);
    return verifier;

but when i pass the code with code_verifier, i get following response from server.

code=400, message=Failed to verify code verifier,

Please guide me how to pass correct code_verifier