'"error_description": "client_secret is missing."

Hello team I have a Application on https://console.cloud.google.com of type Desktop

once after signin with the test user credentials , i have returned successfully and then trying to get the token using the

final String tokenUrl = "https://oauth2.googleapis.com/token";

    // The original redirect URL

    final URI redirectUri = new URI(this.redirectUri);

    // Using HttpClient to make the POST to exchange the auth code for the token

    HttpClient client = HttpClientBuilder.create().build();
    HttpPost post = new HttpPost(tokenUrl);

    // Adding the POST params to the request

    List<NameValuePair> urlParameters = new ArrayList<NameValuePair>();
   
    urlParameters.add(new BasicNameValuePair("code", code));       
    urlParameters.add(new BasicNameValuePair("client_id", googleClientId));
    urlParameters.add(new BasicNameValuePair("client_secret", googleClientsecret));
    urlParameters.add(new BasicNameValuePair("redirect_uri", redirectUri.toString()));
    urlParameters.add(new BasicNameValuePair("scope", scope));
    urlParameters.add(new BasicNameValuePair("grant_type", grantType));

    post.setEntity(new UrlEncodedFormEntity(urlParameters));

    // Execute the request
    System.out.println(post.toString());

    HttpResponse response = client.execute(post);

    // Print the status code

    System.out.println("Response Code : " + response.getStatusLine().getStatusCode());

    // Get the content as a String

    String content = EntityUtils.toString(response.getEntity());

    System.out.println("Result : " + content.toString());

am getting the error as below

Response Code : 400 Result : { "error": "invalid_request", "error_description": "client_secret is missing." }

i know am not using google API's to get the token , but the api here am using also should work right?

please please help me here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source