本文整理了Java中org.scribe.model.Token.<init>()
方法的一些代码示例,展示了Token.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Token.<init>()
方法的具体详情如下:
包路径:org.scribe.model.Token
类名称:Token
方法名:<init>
[英]Default constructor
[中]默认构造函数
代码示例来源:origin: google/data-transfer-project
public static Auth getAuth(AuthData authData, Flickr flickr) throws FlickrException {
checkArgument(
authData instanceof TokenSecretAuthData,
"authData expected to be TokenSecretAuthData not %s",
authData.getClass().getCanonicalName());
TokenSecretAuthData tokenAuthData = (TokenSecretAuthData) authData;
Token requestToken = new Token(tokenAuthData.getToken(), tokenAuthData.getSecret());
return flickr.getAuthInterface().checkToken(requestToken);
}
}
代码示例来源:origin: google/data-transfer-project
SmugMugInterface(
HttpTransport transport,
AppCredentials appCredentials,
TokenSecretAuthData authData,
ObjectMapper mapper)
throws IOException {
this.httpTransport = transport;
this.oAuthService =
new ServiceBuilder()
.apiKey(appCredentials.getKey())
.apiSecret(appCredentials.getSecret())
.provider(SmugMugOauthApi.class)
.build();
this.accessToken = new Token(authData.getToken(), authData.getSecret());
this.mapper = mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
this.user = getUserInformation().getUser();
}
代码示例来源:origin: com.jayway.restassured/rest-assured
public OAuthSigner(String accessToken, OAuthSignature signature) {
this.token = new Token(accessToken, "");
this.signature = signature;
isOAuth1 = false;
}
代码示例来源:origin: com.jayway.restassured/rest-assured
public OAuthSigner(String consumerKey, String consumerSecret,
String accessToken, String secretToken, OAuthSignature signature) {
this.oauthConfig = new OAuthConfig(consumerKey, consumerSecret,
null, getOAuthSigntureType(signature), null, null);
this.token = new Token(accessToken, secretToken);
this.signature = signature;
}
代码示例来源:origin: org.jboss.seam.social/seam-social
/**
* @param token
* @param secret
*/
public OAuthTokenScribe(String token, String secret) {
delegate = new Token(token, secret);
}
代码示例来源:origin: org.scribe/scribe
/**
* Factory method that returns an empty token (token = "", secret = "").
*
* Useful for two legged OAuth.
*/
public static Token empty()
{
return new Token("", "");
}
代码示例来源:origin: tumblr/jumblr
public void setToken(String token, String tokenSecret) {
this.token = new Token(token, tokenSecret);
}
代码示例来源:origin: com.atlassian.jira.plugins/bitbucket-client
public static Token generateAccessTokenObject(String accessToken) {
if (StringUtils.isNotBlank(accessToken)) {
String[] parts = accessToken.split("&");
if (parts.length == 2) {
return new Token(parts[0], parts[1]);
}
}
return null;
}
代码示例来源:origin: org.apache.camel/camel-yammer
public Token extract(String response) {
Preconditions.checkEmptyString(response, "Cannot extract a token from a null or empty String");
Matcher matcher = accessTokenPattern.matcher(response);
if (matcher.find()) {
return new Token(matcher.group(1), "", response);
} else {
throw new OAuthException("Cannot extract an acces token. Response was: " + response);
}
}
代码示例来源:origin: org.scribe/scribe-up
public Token extract(final String response) {
Preconditions.checkEmptyString(response, "Cannot extract a token from a null or empty String");
final Matcher matcher = this.accessTokenPattern.matcher(response);
if (matcher.find()) {
return new Token(matcher.group(1), "", response);
} else {
throw new OAuthException("Cannot extract an acces token. Response was: " + response);
}
}
}
代码示例来源:origin: org.scribe/scribe
public Token extract(String response)
{
Preconditions.checkEmptyString(response, "Cannot extract a token from a null or empty String");
Matcher matcher = accessTokenPattern.matcher(response);
if(matcher.find())
{
return new Token(matcher.group(1), "", response);
}
else
{
throw new OAuthException("Cannot extract an access token. Response was: " + response);
}
}
代码示例来源:origin: tumblr/jumblr
private Token parseXAuthResponse(final Response response) {
String responseStr = response.getBody();
if (responseStr != null) {
// Response is received in the format "oauth_token=value&oauth_token_secret=value".
String extractedToken = null, extractedSecret = null;
final String[] values = responseStr.split("&");
for (String value : values) {
final String[] kvp = value.split("=");
if (kvp != null && kvp.length == 2) {
if (kvp[0].equals("oauth_token")) {
extractedToken = kvp[1];
} else if (kvp[0].equals("oauth_token_secret")) {
extractedSecret = kvp[1];
}
}
}
if (extractedToken != null && extractedSecret != null) {
return new Token(extractedToken, extractedSecret);
}
}
// No good
throw new JumblrException(response);
}
代码示例来源:origin: org.scribe/scribe-up
/**
* Retrieve the user profile from the access token (as String).
*
* @param accessToken
* @return the user profile object
* @throws HttpException
*/
public UserProfile retrieveUserProfile(final String accessToken) throws HttpException {
init();
final Token token = new Token(accessToken, "");
return retrieveUserProfile(token);
}
代码示例来源:origin: org.scribe/scribe
/**
* {@inheritDoc}
*/
public Token extract(String response)
{
Preconditions.checkEmptyString(response, "Response body is incorrect. Can't extract a token from an empty string");
Matcher matcher = Pattern.compile(TOKEN_REGEX).matcher(response);
if (matcher.find())
{
String token = OAuthEncoder.decode(matcher.group(1));
return new Token(token, EMPTY_SECRET, response);
}
else
{
throw new OAuthException("Response body is incorrect. Can't extract a token from this: '" + response + "'", null);
}
}
}
代码示例来源:origin: org.scribe/scribe
/**
* {@inheritDoc}
*/
public Token extract(String response)
{
Preconditions.checkEmptyString(response, "Response body is incorrect. Can't extract a token from an empty string");
String token = extract(response, TOKEN_REGEX);
String secret = extract(response, SECRET_REGEX);
return new Token(token, secret, response);
}
代码示例来源:origin: boncey/Flickr4Java
/**
* Construct a Access Token from a Flickr Response.
*
* @param response
*/
private Token constructToken(Response response) {
Element authElement = response.getPayload();
String oauthToken = XMLUtilities.getChildValue(authElement, "oauth_token");
String oauthTokenSecret = XMLUtilities.getChildValue(authElement, "oauth_token_secret");
Token token = new Token(oauthToken, oauthTokenSecret);
return token;
}
代码示例来源:origin: hoverruan/weiboclient4j
public SinaWeibo2AccessToken getAccessTokenByPassword(String username, String password)
throws WeiboClientException {
SinaWeibo2Api api = new SinaWeibo2Api(GrantType.Password);
OAuthService service = new ServiceBuilder()
.apiKey(clientId)
.apiSecret(clientSecret)
.provider(api)
.build();
return retrieveAccessToken(service, new Token(username, password), null);
}
代码示例来源:origin: hburgmeier/jerseyoauth2
@Test
public void testInvalidResourceAccess()
{
ResourceClient client = new ResourceClient(clientEntity);
try {
client.sendTestRequestSample1(new Token("Invalid",""));
fail();
} catch (ClientException e) {
}
}
代码示例来源:origin: alrocar/POIProxy
@Override
public byte[] download(String URL, String fileName, String downloadPath,
Auth authElem) throws Exception {
AuthTypeEnum authType = AuthTypeEnum.valueOf(authElem.getType());
OAuthService service = new ServiceBuilder().provider(authType._class)
.apiKey(authElem.getApiKey())
.apiSecret(authElem.getApiSecret()).build();
OAuthRequest request = new OAuthRequest(Verb.GET, URL);
Token myToken = new Token(authElem.getAccessToken(),
authElem.getAccessTokenSecret());
service.signRequest(myToken, request);
Response response = request.send();
return response.getBody().getBytes();
}
}
代码示例来源:origin: org.scribe/scribe-up
public void testOk() {
Map<String, String[]> parameters = new HashMap<String, String[]>();
String[] verifiers = new String[] {
VERIFIER
};
String[] tokens = new String[] {
TOKEN
};
parameters.put(BaseOAuth10Provider.OAUTH_VERIFIER, verifiers);
parameters.put(BaseOAuth10Provider.OAUTH_TOKEN, tokens);
SingleUserSession singleUserSession = new SingleUserSession();
singleUserSession.setAttribute(getProvider().getType() + "#" + BaseOAuth10Provider.REQUEST_TOKEN,
new Token(TOKEN, SECRET));
OAuthCredential oauthCredential = getProvider().getCredential(singleUserSession, parameters);
assertNotNull(oauthCredential);
assertEquals(TOKEN, oauthCredential.getToken());
assertEquals(VERIFIER, oauthCredential.getVerifier());
Token tokenRequest = oauthCredential.getRequestToken();
assertEquals(TOKEN, tokenRequest.getToken());
assertEquals(SECRET, tokenRequest.getSecret());
}
内容来源于网络,如有侵权,请联系作者删除!