Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8974793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:44:50+00:00 2026-06-15T18:44:50+00:00

I am trying to obtain an access token from a Java desktop/standalone application using

  • 0

I am trying to obtain an access token from a Java desktop/standalone application using Apache Http:

    StringBuilder sb = new StringBuilder();
    sb.append("code").append('=').append(authorization_code)
      .append('&').append("client_id").append('=').append(client_id)
      .append('&').append("client_secret").append('=').append(client_secret)
      .append('&').append("redirect_uri").append('=').append("urn:ietf:wg:oauth:2.0:oob2")
      .append('&').append("grant_type").append('=').append("authorization_code");

    HttpPost httppost
        = new HttpPost("https://accounts.google.com/o/oauth2/token");
    httppost.setEntity(new StringEntity(sb.toString()));

    System.out.println(httppost.getURI());

    System.out.println(new String(
            EntityUtils.toByteArray(httppost.getEntity())));
    httppost.getEntity().getContent();

    HttpClient httpclient = new DefaultHttpClient();
    HttpResponse resp = httpclient.execute(httppost);

    byte[] ba = EntityUtils.toByteArray(resp.getEntity());
    System.out.println(new String(ba));

The request URL is:

https://accounts.google.com/o/oauth2/token

The content is:

code=4/uktjFRIoKS-VTwADJjO6vSYV3ZyU.Qop5zb7BIj0bOl05ti8ZT3bH57rDdgI
&client_id=128871852795.apps.googleusercontent.com
&client_secret=***********************
&redirect_uri=urn:ietf:wg:oauth:2.0:oob2
&grant_type=authorization_code

and I get:

{
  "error" : "invalid_request"
}

I read the other similar SO questions, but it did not solve my issue.

What am I doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T18:44:50+00:00Added an answer on June 15, 2026 at 6:44 pm

    My mistake. Actually below code

    &redirect_uri=urn:ietf:wg:oauth:2.0:oob2
    

    should be

    &redirect_uri=urn:ietf:wg:oauth:2.0:oob
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey there, I am trying to access raw data from iphone camera using AVCaptureSession.
I'm using Hibernate and JPA for a small project. Somehow when trying to obtain
I'm trying to modify and existing Access application to use MySQL as a database
I have a DataGridView that displays data from a MS Access database. I'm using
I am trying to access the pixels of image using method getRGB(). The image
Trying to obtain blog followers using Tumblr's API and RESTConsole in Chrome (not building
I am currently trying to access the registry, obtain all the sub keys with
Having a MethodDeclarationSyntax Node, I'm trying to access its DocumentationCommentSyntax Node. I can obtain
I'm trying to access an SVN server that I've been using for some time
I'm experiencing problems when trying to access my sharepoint site using web services (on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.