twitter4j.Twitter.getOAuthAccessToken()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(8.1k)|赞(0)|评价(0)|浏览(168)

本文整理了Java中twitter4j.Twitter.getOAuthAccessToken()方法的一些代码示例,展示了Twitter.getOAuthAccessToken()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Twitter.getOAuthAccessToken()方法的具体详情如下:
包路径:twitter4j.Twitter
类名称:Twitter
方法名:getOAuthAccessToken

Twitter.getOAuthAccessToken介绍

[英]Retrieves an access token assosiated with the supplied request token and sets userId.
[中]检索与提供的请求令牌关联的访问令牌,并设置用户ID。

代码示例

代码示例来源:origin: org.twitter4j/twitter4j-async

@Override
public AccessToken getOAuthAccessToken(RequestToken requestToken) throws TwitterException {
  return twitter.getOAuthAccessToken(requestToken);
}

代码示例来源:origin: org.twitter4j/twitter4j-async

@Override
public AccessToken getOAuthAccessToken(String screenName, String password) throws TwitterException {
  return twitter.getOAuthAccessToken(screenName, password);
}

代码示例来源:origin: org.twitter4j/twitter4j-async

@Override
public AccessToken getOAuthAccessToken(RequestToken requestToken, String oauthVerifier) throws TwitterException {
  return twitter.getOAuthAccessToken(requestToken, oauthVerifier);
}

代码示例来源:origin: org.twitter4j/twitter4j-async

/**
 * {@inheritDoc}
 * Basic authenticated instance of this class will try acquiring an AccessToken using xAuth.<br>
 * In order to get access acquire AccessToken using xAuth, you must apply by sending an email to <a href="mailto:api@twitter.com">api@twitter.com</a> all other applications will receive an HTTP 401 error.  Web-based applications will not be granted access, except on a temporary basis for when they are converting from basic-authentication support to full OAuth support.<br>
 * Storage of Twitter usernames and passwords is forbidden. By using xAuth, you are required to store only access tokens and access token secrets. If the access token expires or is expunged by a user, you must ask for their login and password again before exchanging the credentials for an access token.
 *
 * @throws TwitterException When Twitter service or network is unavailable, when the user has not authorized, or when the client application is not permitted to use xAuth
 * @see <a href="https://dev.twitter.com/docs/oauth/xauth">xAuth | Twitter Developers</a>
 */
@Override
public AccessToken getOAuthAccessToken() throws TwitterException {
  return twitter.getOAuthAccessToken();
}

代码示例来源:origin: OpenNMS/opennms

public AccessToken retrieveToken() throws MicroblogAuthorizationException {
  try {
    return m_twitter.getOAuthAccessToken(m_requestToken);
  } catch (final TwitterException e) {
    throw new MicroblogAuthorizationException(e);
  }
}

代码示例来源:origin: OpenNMS/opennms

public AccessToken retrieveToken(final String pin) throws MicroblogAuthorizationException {
  try {
    return m_twitter.getOAuthAccessToken(m_requestToken, pin);
  } catch (final TwitterException e) {
    throw new MicroblogAuthorizationException(e);
  }
}

代码示例来源:origin: stackoverflow.com

System.setProperty("twitter4j.oauth.consumerKey", "your token");
System.setProperty("twitter4j.oauth.consumerSecret", "your token secret");

Twitter twitter = new TwitterFactory().getInstance(login, password);

AccessToken accessToken = twitter.getOAuthAccessToken();

代码示例来源:origin: borax12/Searcher

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  if (resultCode == Activity.RESULT_OK) {
    String verifier = data.getExtras().getString(oAuthVerifier);
    try {
      AccessToken accessToken = twitter.getOAuthAccessToken(requestToken, verifier);
      saveDetails(accessToken);
    } catch (Exception e) {
      Log.e("Twitter Login Failed", e.getMessage());
    }
  }
  super.onActivityResult(requestCode, resultCode, data);
}

代码示例来源:origin: HuygensING/timbuctoo

@Path("/callback")
 @GET
 public Response callback(@QueryParam("oauth_token") String token, @QueryParam("oauth_verifier") String verifier) {

  AccessToken accessToken;
  try {
   accessToken = twitter.getOAuthAccessToken(tokenSecrets.get(token), verifier);

   return Response.ok(accessToken.getToken() + "_" + accessToken.getTokenSecret()).build();
  } catch (Exception e) {
   return Response.status(400).entity("Access Token not found").build();
  }

 }
}

代码示例来源:origin: jchampemont/WTFDYUM

@Override
public AccessToken completeSignin(final RequestToken requestToken, final String verifier) throws WTFDYUMException {
  AccessToken token = null;
  try {
    token = twitter().getOAuthAccessToken(requestToken, verifier);
  } catch (final TwitterException e) {
    log.debug("Error while completeSignin", e);
    throw new WTFDYUMException(e, WTFDYUMExceptionType.TWITTER_ERROR);
  }
  return token;
}

代码示例来源:origin: org.twitter4j/twitter4j-async

@Override
  public void invoke(List<TwitterListener> listeners) throws TwitterException {
    AccessToken token = twitter.getOAuthAccessToken();
    for (TwitterListener listener : listeners) {
      try {
        listener.gotOAuthAccessToken(token);
      } catch (Exception e) {
        logger.warn("Exception at getOAuthRequestTokenAsync", e);
      }
    }
  }
});

代码示例来源:origin: org.twitter4j/twitter4j-async

@Override
  public void invoke(List<TwitterListener> listeners) throws TwitterException {
    AccessToken token = twitter.getOAuthAccessToken(screenName, password);
    for (TwitterListener listener : listeners) {
      try {
        listener.gotOAuthAccessToken(token);
      } catch (Exception e) {
        logger.warn("Exception at getOAuthAccessTokenAsync", e);
      }
    }
  }
});

代码示例来源:origin: org.twitter4j/twitter4j-async

@Override
  public void invoke(List<TwitterListener> listeners) throws TwitterException {
    AccessToken token = twitter.getOAuthAccessToken(requestToken);
    for (TwitterListener listener : listeners) {
      try {
        listener.gotOAuthAccessToken(token);
      } catch (Exception e) {
        logger.warn("Exception at getOAuthRequestTokenAsync", e);
      }
    }
  }
});

代码示例来源:origin: org.twitter4j/twitter4j-async

@Override
  public void invoke(List<TwitterListener> listeners) throws TwitterException {
    AccessToken token = twitter.getOAuthAccessToken(requestToken, oauthVerifier);
    for (TwitterListener listener : listeners) {
      try {
        listener.gotOAuthAccessToken(token);
      } catch (Exception e) {
        logger.warn("Exception at getOAuthAccessTokenAsync", e);
      }
    }
  }
});

代码示例来源:origin: org.twitter4j/twitter4j-async

@Override
  public void invoke(List<TwitterListener> listeners) throws TwitterException {
    AccessToken token = twitter.getOAuthAccessToken(oauthVerifier);
    for (TwitterListener listener : listeners) {
      try {
        listener.gotOAuthAccessToken(token);
      } catch (Exception e) {
        logger.warn("Exception at getOAuthRequestTokenAsync", e);
      }
    }
  }
});

代码示例来源:origin: stackoverflow.com

Twitter twitter = new Twitter();
twitter.setOAuthConsumer(consumerKey,consumerSecret);
AccessToken accessToken =
  twitter.getOAuthAccessToken(token, tokenSecret);
twitter.setOAuthAccessToken(accessToken);

代码示例来源:origin: stackoverflow.com

ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
  configurationBuilder.setOAuthConsumerKey(Consumer__Key);
  configurationBuilder.setOAuthConsumerSecret(Consumer_Secret);
  Configuration configuration = configurationBuilder.build();
  Twitter twitter = new TwitterFactory(configuration).getInstance("username","password"); 
  AccessToken token = twitter.getOAuthAccessToken();
  System.out.println("Access Token " +token );
  String name = token.getScreenName();
  System.out.println("Screen Name" +name);
  PrintWriter out= response.getWriter();
  System.out.println(token);

代码示例来源:origin: stackoverflow.com

Configuration configuration = new ConfigurationBuilder()
.setOAuthConsumerKey("your_customer_key")
.setOAuthConsumerSecret("your_customer_secret")
.build();

Twitter twitter = new TwitterFactory(configuration).getInstance(new BasicAuthorization(username, password)); // yes, use "BasicAuthorization" although that seems strange

AccessToken token = twitter.getOAuthAccessToken();
Log.d(TAG, "Access token: " + token.getToken());
Log.d(TAG, "Access token secret: " + token.getTokenSecret());

代码示例来源:origin: stackoverflow.com

Configuration configuration = new ConfigurationBuilder()
.setOAuthConsumerKey("your_customer_key")
.setOAuthConsumerSecret("your_customer_secret")
.build();

Twitter twitter = new TwitterFactory(configuration).getInstance(new BasicAuthorization("username", "password"));
AccessToken token = twitter.getOAuthAccessToken();

代码示例来源:origin: ORCID/ORCID-Source

/**
 * Get the twitter AccessToken
 * 
 * @return The twitter AccessToken
 * */
private AccessToken getOAuthAccessToken(String orcid, String pin) throws Exception {
  RequestToken requestToken = getTwitterRequestToken(orcid);
  Twitter twitter = new TwitterFactory().getInstance();
  twitter.setOAuthConsumer(twitterKey, twitterSecret);
  return twitter.getOAuthAccessToken(requestToken, pin);
}

相关文章