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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:47:53+00:00 2026-06-05T22:47:53+00:00

How do you exchange Authorization code for a OAuth2 token for google apis in

  • 0

How do you exchange Authorization code for a OAuth2 token for google apis in android? If you go to https://code.google.com/oauthplayground/ you can exchange them, but I need to be able to do it in a android app! Any ideas?

  • 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-05T22:47:56+00:00Added an answer on June 5, 2026 at 10:47 pm

    I found out myself! 🙂

    All you need to do is make a HttpPost to accounts.google.com/o/oauth2/token with the Authorization Code, client id, client secret, redirect_uri and grant type! I added the code to the answer so you can see how to do it exactly! Hope it helps

    HttpClient client = new DefaultHttpClient();
    HttpPost post = new HttpPost("https://accounts.google.com/o/oauth2/token");
    List<NameValuePair> pairs = new ArrayList<NameValuePair>();
    pairs.add(new BasicNameValuePair("code", "<your_auth_code>"));
    pairs.add(new BasicNameValuePair("client_id", "<your_client_id>"));
    pairs.add(new BasicNameValuePair("client_secret", "<your_client_secret>"));
    pairs.add(new BasicNameValuePair("redirect_uri", "<your_redirect_uri>"));
    pairs.add(new BasicNameValuePair("grant_type", "authorization_code")); //Leave this line how it is   
    post.setEntity(new UrlEncodedFormEntity(pairs));
    org.apache.http.HttpResponse response = client.execute(post);
    String responseBody = EntityUtils.toString(response.getEntity());
    Log.v("message", responseBody); // That just logs it into logCat
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Code: import com.independentsoft.exchange.Service; import android.app.Activity; import android.os.Bundle; public class ContactsToExchangeActivity extends Activity { @Override
I have an exchange rate table. I need to get current rate and previous
I need to exchange APDU with a SIM card on a smartphone. I made
Since Exchange doesn't provide support for all local calendar types in OWA, I need
There is just an Exchange account provider pre-installed in the emulator when building Android
Using Exchange Web Services on Exchange Server 2010, I need to look up a
I need to exchange both protobuf-net objects and files between computers and am trying
If you exchange a short-term access token to extend it to 60 days using
Why does Microsoft license Exchange ActiveSync ? Not licensing it will only help them
I need to exchange data between FreeImage (FIBITMAP) and OpenCV format (IplImage and/or Mat).

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.