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 8727499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:26:43+00:00 2026-06-13T08:26:43+00:00

I am trying to integrate the Google Plus API into my web application. I

  • 0

I am trying to integrate the Google Plus API into my web application.

I am able to authenticate with Google and I get the code. The problem occurs when I try getting an access_token using HttpClient.

Here is some code:

DefaultHttpClient httpClient = new DefaultHttpClient();
        HttpPost post = new HttpPost(
                "https://accounts.google.com/o/oauth2/token");
        post.addHeader("accept", "application/json");
        post.addHeader("Content-Type", "application/x-www-form-urlencoded");

        List<NameValuePair> nvps = new ArrayList<NameValuePair>();
        nvps.add(new BasicNameValuePair("code", myCode));
        nvps.add(new BasicNameValuePair("client_id",
                "my_client_id"));
        nvps.add(new BasicNameValuePair("redirect_uri",
                "http://localhost:8080/test/gplus.do"));
        nvps.add(new BasicNameValuePair("client_secret",
                "my_client_secret"));
        nvps.add(new BasicNameValuePair("grant_type", "authorization_code"));
        post.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));

        HttpResponse response = httpClient.execute(post);

        BufferedReader br = new BufferedReader(new InputStreamReader(
                (response.getEntity().getContent())));

        String output;
        while ((output = br.readLine()) != null) {
            res = res + output;
        }

I have managed to get the token in my mock application several times before, but now it seems to be failing for some unknown reason. All I get is error:invalid_grant. Why is this happening?

  • 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-13T08:26:44+00:00Added an answer on June 13, 2026 at 8:26 am

    are you sure u got the token this way before?
    AFAIK, in oAuth, you first call /authorize to get the authorization code, and then, using this code, you make the call to /token to get the access token.

    p.s. you can use packages as Spring for oAuth, so it makes all the “behind-the-scenes” stuff, all you have to do is to configure the XML.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to integrate the Google Data API into my application. I'm using the
I have been trying to integrate Google calendar into a Django application running on
I am trying to integrate Google Docs with my web application which is written
I am trying to integrate the code from this demo: http://code.google.com/p/gwt-spring-starter-app/ into my main
I'm trying to create a redistributable web application that will integrate with Google Analytics
I'm trying to integrate some Google maps bits into my Java web app using
I'm trying to integrate google-code-prettify to my site in order to prettify Java code.
I'm trying to integrate Google Earth into Google Maps, and I saw it was
I'm trying to integrate a Flex app with Google Checkout and code that runs
Iam quite new to Google chart API's and I am trying to integrate it

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.