本文整理匯總了Java中com.github.scribejava.core.model.AbstractRequest類的典型用法代碼示例。如果您正苦於以下問題:Java AbstractRequest類的具體用法?Java AbstractRequest怎麽用?Java AbstractRequest使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
AbstractRequest類屬於com.github.scribejava.core.model包,在下文中一共展示了AbstractRequest類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createAccessTokenRequest
import com.github.scribejava.core.model.AbstractRequest; //導入依賴的package包/類
/**
* ref: https://dev.fitbit.com/docs/oauth2/#access-token-request
* @param code
* @param request
* @param <T>
* @return
*/
@Override
protected <T extends AbstractRequest> T createAccessTokenRequest(String code, T request) {
OAuthConfig config = this.getConfig();
request.addParameter("client_id", config.getApiKey());
request.addParameter("client_secret", config.getApiSecret());
request.addParameter("code", code);
request.addParameter("redirect_uri", config.getCallback());
String scope = config.getScope();
if(scope != null) {
request.addParameter("scope", scope);
}
//this is non-OAuth2 standard, but Fitbit requires it
request.addHeader("Authorization", "Basic " + Base64Encoder.getInstance().encode(String.format("%s:%s", new Object[]{config.getApiKey(), config.getApiSecret()}).getBytes(Charset.forName("UTF-8"))));
request.addParameter("grant_type", "authorization_code");
return request;
}
示例2: createRefreshTokenRequest
import com.github.scribejava.core.model.AbstractRequest; //導入依賴的package包/類
/**
* ref: https://dev.fitbit.com/docs/oauth2/#refreshing-tokens
* @param refreshToken
* @param request
* @param <T>
* @return
*/
@Override
protected <T extends AbstractRequest> T createRefreshTokenRequest(String refreshToken, T request) {
if(refreshToken != null && !refreshToken.isEmpty()) {
OAuthConfig config = this.getConfig();
request.addParameter("client_id", config.getApiKey());
request.addParameter("client_secret", config.getApiSecret());
request.addParameter("refresh_token", refreshToken);
request.addParameter("grant_type", "refresh_token");
//this is non-OAuth2 standard, but Fitbit requires it
request.addHeader("Authorization", "Basic " + Base64Encoder.getInstance().encode(String.format("%s:%s", new Object[]{config.getApiKey(), config.getApiSecret()}).getBytes(Charset.forName("UTF-8"))));
return request;
} else {
throw new IllegalArgumentException("The refreshToken cannot be null or empty");
}
}
示例3: createAccessTokenRequest
import com.github.scribejava.core.model.AbstractRequest; //導入依賴的package包/類
protected <T extends AbstractRequest> T createAccessTokenRequest(String code, T request) {
final OAuthConfig config = getConfig();
request.addParameter("appid", config.getApiKey());
request.addParameter("secret", config.getApiSecret());
request.addParameter(OAuthConstants.CODE, code);
request.addParameter(OAuthConstants.GRANT_TYPE, OAuthConstants.AUTHORIZATION_CODE);
return request;
}
示例4: createRefreshTokenRequest
import com.github.scribejava.core.model.AbstractRequest; //導入依賴的package包/類
protected <T extends AbstractRequest> T createRefreshTokenRequest(String refreshToken, T request) {
if (refreshToken == null || refreshToken.isEmpty()) {
throw new IllegalArgumentException("The refreshToken cannot be null or empty");
}
final OAuthConfig config = getConfig();
request.addParameter("appid", config.getApiKey());
request.addParameter("secret", config.getApiSecret());
request.addParameter(OAuthConstants.REFRESH_TOKEN, refreshToken);
request.addParameter(OAuthConstants.GRANT_TYPE, OAuthConstants.REFRESH_TOKEN);
return request;
}
示例5: signRequest
import com.github.scribejava.core.model.AbstractRequest; //導入依賴的package包/類
@Override
public void signRequest(final OAuth2AccessToken accessToken, final AbstractRequest request) {
request.addQuerystringParameter("oauth_token", accessToken.getAccessToken());
}
示例6: signRequest
import com.github.scribejava.core.model.AbstractRequest; //導入依賴的package包/類
@Override
public void signRequest(OAuth2AccessToken accessToken, AbstractRequest request) {
request.addQuerystringParameter("oauth2_access_token", accessToken.getAccessToken());
}