本文整理汇总了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());
}