"error_description": "client_secret is missing."

Skip to first unread message

Vishwa Varanasi

May 16, 2022, 6:16:07 PMMay 16
to gce-discussion

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 code successfully and then trying to get the token using thecode

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

Andres Fiesco Casasola

May 17, 2022, 3:49:43 PMMay 17
to gce-discussion

Could you please share the documentation that you used to come up with your code? I'm checking Google’s documentation, and according to [1] and [2], you need to set up a project in the Google API console first before you can use OAuth 2.0. 

   -    [1]:https://developers.google.com/identity/protocols/oauth2/openid-connect 

   -    [2]:https://developers.google.com/identity/protocols/oauth2
Reply all
Reply to author
0 new messages