本文整理了Java中org.scribe.model.Token
类的一些代码示例,展示了Token
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Token
类的具体详情如下:
包路径:org.scribe.model.Token
类名称:Token
[英]Represents an OAuth token (either request or access token) and its secret
[中]表示OAuth令牌(请求或访问令牌)及其秘密
代码示例来源: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
@Override
public String getAuthorizationUrl(Token requestToken) {
return "https://secure.smugmug.com/services/oauth/1.0a/authorize?oauth_token="
+ requestToken.getToken();
}
}
代码示例来源: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());
}
代码示例来源:origin: boncey/Flickr4Java
/**
* Returns the credentials attached to an OAuth authentication token.
*
* @param accessToken
* The authentication token
* @return The Auth object
* @throws FlickrException
*/
public Auth checkToken(Token accessToken) throws FlickrException {
return checkToken(accessToken.getToken(), accessToken.getSecret());
}
代码示例来源:origin: org.scribe/scribe-up
public void testOAuthCredential() {
OAuthCredential credential = new OAuthCredential(REQUEST_TOKEN, TOKEN, VERIFIER, TYPE);
assertEquals(TOKEN, credential.getToken());
assertEquals(VERIFIER, credential.getVerifier());
assertEquals(TYPE, credential.getProviderType());
Token requestToken = credential.getRequestToken();
assertEquals(TOKEN, requestToken.getToken());
assertEquals(SECRET, requestToken.getSecret());
// test serialization
byte[] bytes = CommonHelper.serialize(credential);
OAuthCredential credential2 = (OAuthCredential) CommonHelper.unserialize(bytes);
assertEquals(credential.getRequestToken().toString(), credential2.getRequestToken().toString());
assertEquals(credential.getToken(), credential2.getToken());
assertEquals(credential.getVerifier(), credential2.getVerifier());
assertEquals(credential.getProviderType(), credential2.getProviderType());
}
}
代码示例来源:origin: org.scribe/scribe-up
@Override
public void signRequest(final Token token, final OAuthRequest request) {
this.config.log("signing request: " + request.getCompleteUrl());
// Do not append the token if empty. This is for two legged OAuth calls.
if (!token.isEmpty()) {
request.addOAuthParameter(OAuthConstants.TOKEN, token.getToken());
}
this.config.log("setting token to: " + token);
addOAuthParams(request, token);
appendSignature(request);
}
代码示例来源:origin: zrk1000/oauthclient
@Override
public void signRequest(Token accessToken, OAuthRequest request) {
request.addQuerystringParameter(OAuthConstants.ACCESS_TOKEN, accessToken.getToken());
final JsonNode json = JsonHelper.getFirstNode(accessToken.getRawResponse());
String openid = (String) JsonHelper.get(json, "openid");
request.addQuerystringParameter("openid", openid);
}
代码示例来源:origin: org.jboss.seam.social/seam-social
public String getSecret() {
return delegate.getSecret();
}
代码示例来源:origin: jenkinsci/bitbucket-build-status-notifier-plugin
private FormValidation checkCredentials(UsernamePasswordCredentials credentials) {
try {
OAuthConfig config = new OAuthConfig(credentials.getUsername(), credentials.getPassword().getPlainText());
BitbucketApiService apiService = (BitbucketApiService) new BitbucketApi().createService(config);
Verifier verifier = null;
Token token = apiService.getAccessToken(OAuthConstants.EMPTY_TOKEN, verifier);
if (token.isEmpty()) {
return FormValidation.error("Invalid Bitbucket OAuth credentials");
}
} catch (Exception e) {
return FormValidation.error(e.getClass() + e.getMessage());
}
return FormValidation.ok();
}
}
代码示例来源:origin: zrk1000/oauthclient
@Override
protected String getProfileUrl(Token accessToken) {
final JsonNode json = JsonHelper.getFirstNode(accessToken.getRawResponse());
String uid = (String) JsonHelper.get(json, "uid");
return "https://api.weibo.com/2/users/show.json?uid="+uid;
}
代码示例来源:origin: de.esoco/esoco-oauth
/***************************************
* {@inheritDoc}
*/
@Override
public String processCallback(String sCallbackCode) throws Exception
{
Verifier aVerifier = new Verifier(sCallbackCode);
Entity rUser = getUser();
Token rToken =
aOAuthService.getAccessToken(getRequestToken(aOAuthService),
aVerifier);
String sAccessToken = rToken.getToken();
String sRefreshToken = rToken.getSecret();
rUser.set(getAccessTokenRelationType(), sAccessToken);
if (sRefreshToken.isEmpty())
{
sRefreshToken = null;
}
Configuration rSettings = Configuration.getSettings(rUser, true);
rSettings.setExtraAttribute(getRefreshTokenExtraAttribute(),
sRefreshToken);
EntityManager.storeEntity(rSettings, rUser);
return sAccessToken;
}
代码示例来源:origin: org.scribe/scribe
/**
* {@inheritDoc}
*/
public void signRequest(Token token, OAuthRequest request)
{
config.log("signing request: " + request.getCompleteUrl());
// Do not append the token if empty. This is for two legged OAuth calls.
if (!token.isEmpty())
{
request.addOAuthParameter(OAuthConstants.TOKEN, token.getToken());
}
config.log("setting token to: " + token);
addOAuthParams(request, token);
appendSignature(request);
}
代码示例来源:origin: evernote/evernote-sdk-android
try {
Token accessToken = mOAuthService.getAccessToken(mRequestToken, verifier);
String rawResponse = accessToken.getRawResponse();
String authToken = accessToken.getToken();
String noteStoreUrl = extract(rawResponse, NOTE_STORE_REGEX);
String webApiUrlPrefix = extract(rawResponse, WEB_API_REGEX);
代码示例来源:origin: stackoverflow.com
Token accessToken = service.getAccessToken(flickReq, v); // Original accessToken you get from Flickr and users entered code.
String tokenSecret = accessToken.getSecret();
代码示例来源:origin: org.scribe/scribe
@Override
public String getAuthorizationUrl(Token requestToken)
{
return "https://www.dropbox.com/1/oauth/authorize?oauth_token="+requestToken.getToken();
}
代码示例来源: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: hoverruan/weiboclient4j
request.addBodyParameter(OAuthConstants.REDIRECT_URI, config.getCallback());
} else if (api.getGrantType() == GrantType.Password && requestToken != null) {
request.addBodyParameter(USERNAME, requestToken.getToken());
request.addBodyParameter(PASSWORD, requestToken.getSecret());
代码示例来源:origin: org.scribe/scribe-up
private String getSignature(final OAuthRequest request, final Token token) {
this.config.log("generating signature...");
final String baseString = this.api.getBaseStringExtractor().extract(request);
final String signature = this.api.getSignatureService().getSignature(baseString, this.config.getApiSecret(),
token.getSecret());
this.config.log("base string is: " + baseString);
this.config.log("signature is: " + signature);
return signature;
}
代码示例来源:origin: org.scribe/scribe
/**
* {@inheritDoc}
*/
@Override
public String getAuthorizationUrl(Token requestToken)
{
return "http://www.flickr.com/services/oauth/authorize?oauth_token=" + requestToken.getToken();
}
代码示例来源:origin: com.jayway.restassured/rest-assured
public OAuthSigner(String accessToken, OAuthSignature signature) {
this.token = new Token(accessToken, "");
this.signature = signature;
isOAuth1 = false;
}
内容来源于网络,如有侵权,请联系作者删除!