當前位置: 首頁>>代碼示例>>Java>>正文


Java AbstractRequest類代碼示例

本文整理匯總了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;
}
 
開發者ID:alexthered,項目名稱:fitbitAPI20-scribe-java,代碼行數:26,代碼來源:Fitbit20ServiceImpl.java

示例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");
    }
}
 
開發者ID:alexthered,項目名稱:fitbitAPI20-scribe-java,代碼行數:25,代碼來源:Fitbit20ServiceImpl.java

示例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;
}
 
開發者ID:perrywang,項目名稱:OAuthGateway,代碼行數:9,代碼來源:WeixinOAuthService.java

示例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;
}
 
開發者ID:perrywang,項目名稱:OAuthGateway,代碼行數:12,代碼來源:WeixinOAuthService.java

示例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());
}
 
開發者ID:yaochi,項目名稱:pac4j-plus,代碼行數:5,代碼來源:Foursquare20Service.java

示例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());
}
 
開發者ID:perrywang,項目名稱:OAuthGateway,代碼行數:5,代碼來源:LinkedInOAuthService.java


注:本文中的com.github.scribejava.core.model.AbstractRequest類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。