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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T07:52:18+00:00 2026-06-06T07:52:18+00:00

I have the following on a web servlet: EDITED: public String tryGoogleAuthentication(String auth_token){ HttpURLConnection

  • 0

I have the following on a web servlet:

EDITED:

public String tryGoogleAuthentication(String auth_token){

    HttpURLConnection connection = null;
    try {

        //connection = (HttpURLConnection) new URL(("https://www.googleapis.com/oauth2v1/tokeninfo?access_token={"+auth_token+"}")).openConnection();
       connection = (HttpURLConnection) new URL(("https://www.googleapis.com/oauth2/v1/user info")).openConnection();
       connection.setRequestMethod("GET");          
       connection.setRequestProperty("Authorization", "Bearer {"+auth_token+"}");
       connection.setRequestProperty("Host", "googleapis.com");

        //read response
        String response = fromInputStreamToString(connection.getInputStream());
        System.out.println(response);

    } catch (MalformedURLException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    return CONST.STATUS_OK;
}

In android:

    private void googleAuthenticate(){
    try {
        mOAauthHelper = new OAuthHelper("something.net", "xxxxxxxxxx", 
                "https://www.googleapis.com/auth/userinfo.profile", "alex://myScheme");
        String uri = mOAauthHelper.getRequestToken();

        startActivity(new Intent("android.intent.action.VIEW", Uri.parse(uri)));

                    //Intent i = new Intent(this, GoogleOAUTHActivity.class);
                    //i.putExtra(GoogleOAUTHActivity.GOOGLE_OAUTH_ENDPOINT_KEY, uri);           
                     //startActivity(i);

    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
        failedAuthenticatingAtGoogle();
    } catch (OAuthMessageSignerException e) {
        e.printStackTrace();
        failedAuthenticatingAtGoogle();
    } catch (OAuthNotAuthorizedException e) {
        e.printStackTrace();
        failedAuthenticatingAtGoogle();
    } catch (OAuthExpectationFailedException e) {
        e.printStackTrace();
        failedAuthenticatingAtGoogle();
    } catch (OAuthCommunicationException e) {
        e.printStackTrace();
        failedAuthenticatingAtGoogle();
    }
}

and

@Override
protected void onNewIntent(Intent intent) {
    //super.onNewIntent(intent);

    Uri uri = intent.getData();
    String oauthToken = uri.getQueryParameter("oauth_token");
    String oauthVerifier = uri.getQueryParameter("oauth_verifier");

    if(oauthToken != null){
        authorizeGoogleSessionToServer(oauthToken);
    }
}

After this, I send the request token to my servlet where I tried to get user profile, but with no success.

Could you please tell me what’s wrong and why I’m getting error 400 from google?

Thanks.

  • 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-06T07:52:19+00:00Added an answer on June 6, 2026 at 7:52 am

    Unfortunately, I can see a few issues with this already

    1. you should never have curly braces in your URL or even in the Bearer header as stated in the draft.

    connection = (HttpURLConnection) new URL(("https://www.googleapis.com/oauth2/v1/userinfo?access_token={"+auth_token+"}")).openConnection()

    1. 400 means that you’re missing something in your request, there is probably more information about it in the same response as specific error node.

    2. Finally, take care, oauth_verifier param is from OAuth 1.

    I suggest you test your request URL’s, using the Google OAuth2 playground

    Good luck!

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

Sidebar

Related Questions

I'm new to Spring MVC and have the following situation: In WEB-INF/demoshop-servlet.xml I have
I have following situation: String a = A Web crawler is a computer program
I have the following servlet coded in /src/main/java/examples/web/SimpleServlet.java : package examples.web; import java.io.IOException; import
The following web.xml doesn't seem to work: <servlet-mapping> <servlet-name>MyServlet</servlet-name> <url-pattern>*.wfn</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>SelectSessionServer.wfn</welcome-file> </welcome-file-list>
I have the following servlet code public void doPost(HttpServletRequest request, HttpServletResponse response){ Backup bup
In web.xml I have the following: <servlet> <description>JAX-WS endpoint - EARM</description> <display-name>jaxws-servlet</display-name> <servlet-name>jaxws-servlet</servlet-name> <servlet-class>com.sun.xml.ws.transport.http.servlet.WSSpringServlet</servlet-class>
I have the following xml block (a standard jboss web.xml file) : <web-app> <servlet>
Hi I have th following Servlet in a new Google App Engine (SDK 1.6.6)
I have the following Web page: link to page . If you go to
I am using IIS V5.1. Integrated windows authentication I have a following web config:

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.