当前位置: 首页>>代码示例>>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;未经允许,请勿转载。