How to use google-oauth-java-client?

Tags: ,

I want to use google-oauth-java-client to get authorization code from Sina Weibo.

This is the GET method that get code from Sina

Please solve this without web page, only client!

Can anybody give me some advise?


sI’m sorry that I make a mistake! Get method use browser and return the code Post method use HttpRequest and we can get parameter from HtppResponse

So if you want to get code ,just use browser and redirect to the url to get code

Here is how I get access_token

If you want, you can use google-oauth-java-client to authorization twitter facebook

I solve this by javadoc which show me some examples This is the root of JavaDoc This is the package I use to solve Here is the example I write

// server url example
try {
  TokenResponse response =
      new AuthorizationCodeTokenRequest(new NetHttpTransport(), new JacksonFactory(),
          new GenericUrl("here is the server url "), "here write your code")
          .setRedirectUri("here write the redirectUrl")
          .set("client_id","here write your client_id")
          .set("client_secret","here write your client_secret")
          .set("Other else need","Other else need")
  System.out.println("Access token: " + response.getAccessToken());
} catch (TokenResponseException e) {
  if (e.getDetails() != null) {
    System.err.println("Error: " + e.getDetails().getError());
    if (e.getDetails().getErrorDescription() != null) {
    if (e.getDetails().getErrorUri() != null) {
  } else {

Source: stackoverflow